[stringtemplate-interest] it's 60% of time in ObjectModelAdaptor.getProperty()

Oliver Zeigermann oliver.zeigermann at gmail.com
Sun Feb 6 08:44:59 PST 2011


2011/2/6 Johan Stuyts <j.stuyts at javathinker.com>:
>> Another problem with compiling to bytecode is that for each
>> compilation you have a new class lurking around. You can still reuse
>> them, but getting rid of them (unloading) would probably require a
>> classloader for each new class:
>>
>> http://stackoverflow.com/questions/148681/unloading-classes-in-java
>
> I believe classes are properly garbage collected in modern JVMs, so you
> don't have to worry about that and can use a single class loader for all
> adapters. But this should be tested to be sure.

Yes, classes are garbage collected, but as they have a reference to
their class loader, they won't be garbage until the class loader is
garbage. Which can only be when you have created it. Or am I missing
anything here?

> One problem with custom class loaders is that in secure environments you
> need to have permissions to be able to create one. But as many frameworks
> use custom class loaders nowadays, this is not a problem in most cases, I
> guess.

When dynamically loading classes from byte arrays I do not know of any
other way than creating your own class loader anyway. I sure know that
the - know to be picky - Google App Engine allows you to do so - as I
tried it :)

Does that make sense?

- Oliver


More information about the stringtemplate-interest mailing list