Package de.sandec.jmemorybuddy
Class JMemoryBuddy
- java.lang.Object
-
- de.sandec.jmemorybuddy.JMemoryBuddy
-
public class JMemoryBuddy extends java.lang.ObjectJMemoryBuddy 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 Classes Modifier and Type Class Description static interfaceJMemoryBuddy.MemoryTestAPIThis class provides different methods, which can be used to declare memory-constraints.
-
Constructor Summary
Constructors Constructor Description JMemoryBuddy()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidassertCollectable(java.lang.ref.WeakReference weakReference)Checks whether the content of the WeakReference can be collected.static voidassertNotCollectable(java.lang.ref.WeakReference weakReference)Checks whether the content of the WeakReference cannot be collected.static booleancheckCollectable(java.lang.ref.WeakReference weakReference)Checks whether the content of the WeakReference can be collected.static booleancheckNotCollectable(java.lang.ref.WeakReference weakReference)Checks whether the content of the WeakReference cannot be collected.static voidmemoryTest(java.util.function.Consumer<JMemoryBuddy.MemoryTestAPI> f)A standard method to define a test which checks code for specific memory semantic.
-
-
-
Method Detail
-
assertCollectable
public static void assertCollectable(java.lang.ref.WeakReference weakReference)
Checks whether the content of the WeakReference can be collected.- Parameters:
weakReference- The WeakReference to check.
-
checkCollectable
public static boolean checkCollectable(java.lang.ref.WeakReference weakReference)
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
public static void assertNotCollectable(java.lang.ref.WeakReference weakReference)
Checks whether the content of the WeakReference cannot be collected.- Parameters:
weakReference- The WeakReference to check.
-
checkNotCollectable
public static boolean checkNotCollectable(java.lang.ref.WeakReference weakReference)
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
public static void memoryTest(java.util.function.Consumer<JMemoryBuddy.MemoryTestAPI> f)
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.
-
-