Hi all, 

I have a problem which classloading and ant 1.8.1, junit 4.8.2 and log4j
1.2.16 or any 
third-party libraries: 

<junit reloading="true"> 
<classpath refid="junit.classpath.ref"/> 
<batchtest fork="false"> 
<fileset refid="${test-fileset-refid}"/> 
</batchtest> 
..... 
</junit> 

with the classpath: 
<fileset dir="${modules.dir}"> 
<include name="**/lib*/*.jar" /> 
<exclude name="**/**/log4j.jar"/> 
</fileset> 

Following target is called: 
<target name="only.junit4.example"> 
<antcall target="only.junit4.example1"/> 
<antcall target="only.junit4.example2"/> 
</target>

only.junit4.example1 and only.junit4.example2 both call the target with
junit-call above 
with different filesets. 

in the testclasses of both antcalls I have static variables private
static LOGGER = Logger.getLogger(... .class);

If I create a heapdump after the second target there's the following
behaviour: 

1. If I remove exclude log4j from fileset, two SplitClassLoader-instance
are still available, which seem to be never gc'd
2. If I start it with the exclude-tag, but give log4j with -lib to ant,
both splitcalssloaders are gc'd correctly, but it seems there are
multiple AntClassLoader5-instance not gc'd

Problem: 

Without forking every testcase (not suite) the memory-usage increases
step by step, because neither the classloaders nor any static reference
is gcd (singletons from legacycode). 
After half my tests have run, I get a PermGenSpace-OOM (configured 500M
for permgenspace)

1. Is this behaviour of the classloaders a behaviour you would expect or
do we have a classloader-leak?
2. Do we have to cleanup all statics and singletons to decrease
memory-footprint or does a generic solution exist?
3. parameter -lib is only a workaround, isn't it? How should we give the
libs to ant? 
4. Is it possible to use reloading="false"? I guess I didn't have any
other behaviour

Any help welcome 

Thank you by now 
Markus

Reply via email to