Package soot.jimple.infoflow.memory
Class MemoryWarningSystem
java.lang.Object
soot.jimple.infoflow.memory.MemoryWarningSystem
Notification system that triggers a callback when the JVM is about to run out
of memory. Inspired by code from
http://www.javaspecialists.eu/archive/Issue092.html.
Be careful, because memory allocation is usually fast. There might not be a
lot of time left to perform corrective measures if the warning threshold is
reached.
- Author:
- Steven Arzt, Marc Miltenberger
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface that is invoked when a certain memory threshold has been reached. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a listener that is called when the memory usage threshold defined using setWarningThreshold() has been reachedvoidclose()Closes this warning system instance.protected voidfinalize()static MemoryPoolMXBeanTenured Space Pool can be determined by it being of type HEAP and by it being possible to set the usage threshold.voidsetWarningThreshold(double percentage) Sets the one single global warning threshold for memory usage.
-
Constructor Details
-
MemoryWarningSystem
public MemoryWarningSystem()
-
-
Method Details
-
finalize
-
addListener
Adds a listener that is called when the memory usage threshold defined using setWarningThreshold() has been reached- Parameters:
listener- The listener to add
-
findTenuredGenPool
Tenured Space Pool can be determined by it being of type HEAP and by it being possible to set the usage threshold. -
setWarningThreshold
public void setWarningThreshold(double percentage) Sets the one single global warning threshold for memory usage. If at least the given fraction of the overall tenured pool is in use, the registered hanlders will be invoked.- Parameters:
percentage-
-
close
public void close()Closes this warning system instance. It will no longer notify any listeners of memory shortages.
-