Monday, December 20, 2010

Memory Management #1

Dominator Object:
What is Dominator Object? In what circumstances does this thing
happen?. Remember I'm a programmer and I do code. But how the heck
this thing happen? Easy there folks. Lets go through this from the
very bottom of it.
As usual, we start with our lovely but deadly controller. It control our code.
While at logic level, we have our service class. It does the logic and
control data parsing inside the logics. At data level, we have our
models. We may also have the ORM as part of our model. View? Included.
Jsp for view, enough.
But hey, enough with the chat. Now, let's see, when did Dominator
objects happened and what is the effect of having Dominator object.
Not so long time ago, I declare of ORM inside my MainModel (assuming
that MainModel is the model that I used as model in our case). My
program runs. The logical output was true, and the page went well.
(I'll attach picture later, I do post from mobile you know? :) )
Dao/VO declared in model. Easy to call but remain in memory untill full GC is performed.

what's wrong with above method? While development and testing, my
bosses found out Memory Issue. Sometime, small Instance that hold
approximate 10 to 20 application will easily do full GC in every hour
basis. It shows serious memory problem. When I declare another class
in a class (Dominator Objects?), though I've nulled the value when not
in use, sometime, they do stay in memory and cleared once Full GC
done.
How to overcome this kind of problem? If the problem started because
of stacked class inside other class, one quick simple solution was to
clear that stacked class. Just carry the value youu need and leave
behind everything as history. This way, I believe GC will happen
faster. Well, theoritically I guess LOL. (Again, I will attach the
picture soon).

Dao/VO called in service only when program call specific function.

So now we see, how Dominator Object effect the application memory and
how to overcome this problem. Any question? As usual, you are welcome
to raise question + comments in comment section. Your feedback will
much appreciated. (maybe I'll edit this post with further reading).


Further reading:

http://www.eclipse.org/mat/about/screenshots.php
http://www.slideshare.net/guest62fd60c/eclipse-memory-analyzer-presentation

PS: next post: How to programatically done this?

No comments: