Package de.sandec.jmemorybuddy
Class JMemoryBuddy
java.lang.Object
de.sandec.jmemorybuddy.JMemoryBuddy
JMemoryBuddy provides various methods to test for memory leaks.
It makes it easy to verify the memory behavior in a unit test ensuring the stability and quality of your code.
Checkout https://github.com/Sandec/JMemoryBuddy for more documentation.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThis class provides different methods, which can be used to declare memory-constraints. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertCollectable(WeakReference weakReference) Checks whether the content of the WeakReference can be collected.static voidassertNotCollectable(WeakReference weakReference) Checks whether the content of the WeakReference cannot be collected.static booleancheckCollectable(WeakReference weakReference) Checks whether the content of the WeakReference can be collected.static booleancheckNotCollectable(WeakReference weakReference) Checks whether the content of the WeakReference cannot be collected.static voidA standard method to define a test which checks code for specific memory semantic.
-
Constructor Details
-
JMemoryBuddy
public JMemoryBuddy()
-
-
Method Details
-
assertCollectable
Checks whether the content of the WeakReference can be collected.- Parameters:
weakReference- The WeakReference to check.
-
checkCollectable
Checks whether the content of the WeakReference can be collected.- Parameters:
weakReference- The WeakReference to check.- Returns:
- Returns true, when the provided WeakReference can be collected.
-
assertNotCollectable
Checks whether the content of the WeakReference cannot be collected.- Parameters:
weakReference- The WeakReference to check.
-
checkNotCollectable
Checks whether the content of the WeakReference cannot be collected.- Parameters:
weakReference- The WeakReference to check.- Returns:
- Returns true, when the provided WeakReference cannot be collected.
-
memoryTest
A standard method to define a test which checks code for specific memory semantic. The parameter of the lambda provides an API to define the required memory semantic.- Parameters:
f- A function which get's executed with the API to define the required memory semantic.
-