Am 11.08.2014 22:21, schrieb Steve Amerige:
[...]
> We're hitting *permgen *errors I'm wondering if I've hit the same
> issue. What do you think?
on the JVM a the class loader is part of the identity of a class.
Without the loader the class cannot exist.On the other hand, the
classloader is supposed to return the same class for each loadClass
request. As a result the class loaders do have to cache what classes
they define.
GroovyShell spawns one internal loader, but unless you do something, all
classes every defined by it will continue to exist. The loader there is
a GroovyClassLoader, which you can get by shell.getClassLoader(). Now
GroovyClassLoader is actually a forest of sub loaders allowing us to
violate the rules above a bit. It spawns a sub classloader for every
compilation and does not cache these loaders, only their defined
classes. If you call cleanCache() on the GroovyClassLoader, it will then
forget about all those classes and the classes become collectable by the
JVM (as long as they are not referenced elsewhere)
So if you know you will evaluate often you can always do
shell.getClassLoader().cleanCache() after X steps. If you need more fine
control, then you can still clean the cache, but may have to do
something else to keep the classes available.
bye blackdrag
--
Jochen "blackdrag" Theodorou - Groovy Project Tech Lead
blog:
http://blackdragsview.blogspot.com/
german groovy discussion newsgroup: de.comp.lang.misc
For Groovy programming sources visit
http://groovy-lang.org
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email