cern::util::testhelpers::GarbageCollectionTestHelper Class Reference
List of all members.
Detailed Description
A helper class to check if Garbage Collection works properly. It allows you to check whether an object is freed by the Garbage Collector.
To check whether an object is garbage collected, create an instance of this class and pass it the reference the object in to be surveilled for GC. Then, call the method waitForGC()
to wait until the object is garbage collected. Here is sample code:
Object obj = new Object();
GarbageCollectionTestHelper gch = new GarbageCollectionTestHelper(obj);
obj = null; // enable garbage collection
if (gch.waitForGC(maxTimeoutMillis)) {
System.out.println("garbage collection ok");
} else {
System.err.println("garbage collection problem");
}
You have to use one instance of this class per reference you want to surveil.
This implementation isbased on the java.lang.ref.* classes. It keeps a PhantomReference to the reference and waits until the instance has been garbage collected.
- Version:
- 0.9.1
- Author:
- Vito Baggiolini
Constructor & Destructor Documentation
cern::util::testhelpers::GarbageCollectionTestHelper::GarbageCollectionTestHelper |
( |
Object |
refToSurveil |
) |
[inline] |
|
Member Function Documentation
void cern::util::testhelpers::GarbageCollectionTestHelper::cancel |
( |
|
) |
[inline] |
|
boolean cern::util::testhelpers::GarbageCollectionTestHelper::complexWaitForGC |
( |
long |
maxTimeout |
) |
[inline] |
|
|
a more sophisticated algorithm to wait for Property Change Events |
boolean cern::util::testhelpers::GarbageCollectionTestHelper::waitForGC |
( |
long |
maxTimeout |
) |
[inline] |
|
|
a simple algorithm to wait for GC |
boolean cern::util::testhelpers::GarbageCollectionTestHelper::waitForGC |
( |
|
) |
[inline] |
|
Member Data Documentation
The documentation for this class was generated from the following file:
Generated on Thu Apr 30 03:09:49 2009 for ACS Java API by
1.3.8