Tassilo Horn <tassilo@member.fsf.org> writes:
Hi again,
So if you want to load 10000 classes in a single ClassLoader, then
you will have to size PermGen such that all 10000 classes fit
simultaneously.
If you want to forget some classes, then you will have to create
distinct ClassLoader instances. Maybe each of your defined classes
could use a specific ClassLoader ?
If you are right, a distinct ClassLoader for each schema would make
much sense.
Ok, now I've done that. Our ClassLoader is now a "multi-singleton",
where the instances are held in a Map from schemaName to ClassLoader.
Whenever I don't need a schema anymore, I release its ClassLoader and
call System.gc(). I track the number of ClassLoaders, and it's at most
3, which is correct.
Unfortunately, I still get the OutOfMemoryError: PermGen, although if
the classes were really freed from the permanent generation, I should
need about half the space I needed before that change.
Is there some way to check, if someone still references the ClassLoader
or any Object of a class loaded by that ClassLoader?
Bye,
Tassilo
You can inspect memory using most popular profilers. I prefer JProfiler.
It is a commercial app, but they have a trial period. JProbe is
another option, and netbeans comes with a free one. I haven't used any
that regard.
problem.