persistence@glassfish.java.net

Help? - Finalization testing (GF 1309)

From: Tom Ware <tom.ware_at_oracle.com>
Date: Mon, 06 Nov 2006 13:50:34 -0500

Hi all,

  I have fixed a bug related to a memory leak and am trying to add some
automated testing. My initial test makes use of the test case provided
in the bug to count instances that are instantiated and reduce the count
as the instances are finalized. When the test case is done, I invoke
the garbage collector and give it some time to complete.

  The above test seems to work in a simple case, but as I add complexity
to my test environment, the garbage collector does not reliably clean up
the instances in the time I have allocated (or even if I increase the
time by an order of magnitude - but does eventually clean up)

  Can anyone suggest a better way to test to ensure finalization occurs
properly in an environment where the test environment is consistently
changing and it is not predetermined what VM the tests will run on.

-Tom