Version 1
    We have a classloader leak test in the AS that does both of the above.


    The former caused all kinds of hudson issues, usually because the JVMgets into strange states/dealys when you repeatedly fill all heap space.


    The latter however works very reliably. The solution to the portability problem is IMO, to separate the leak testing from the main testsuite, and then run that on a dedicated platform. If you have a real Java memory leak, it should show up on every OS, but probably not every JVM.




    JBoss Profiler has something there to force memory leaks for you via jmti.




    Byteman? :-)


    You could inject a rule that invokes the GC when a certain method is
    invoked or condition exists?


    Byteman is ridiculously easy to setup and use, especially for testing
    like this.




    Take a look at

    to see it in use.