Class MemoryWarningSystem

java.lang.Object
soot.jimple.infoflow.memory.MemoryWarningSystem

public class MemoryWarningSystem extends Object
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
  • Constructor Details

    • MemoryWarningSystem

      public MemoryWarningSystem()
  • Method Details

    • finalize

      protected void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • addListener

      public void addListener(MemoryWarningSystem.OnMemoryThresholdReached listener)
      Adds a listener that is called when the memory usage threshold defined using setWarningThreshold() has been reached
      Parameters:
      listener - The listener to add
    • findTenuredGenPool

      public static MemoryPoolMXBean 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.