Class ViewJFrameMemory.MemoryMonitor

java.lang.Object
gov.nih.mipav.view.ViewJFrameMemory.MemoryMonitor
All Implemented Interfaces:
FocusListener, Runnable, EventListener
Enclosing class:
ViewJFrameMemory

public class ViewJFrameMemory.MemoryMonitor extends Object implements Runnable, FocusListener
Tracks Memory allocated invalid input: '&' used, and notifies anybody who is interested in finding out about it.
  • Field Details

    • changeEvent

      private ChangeEvent changeEvent
      DOCUMENT ME!
    • counterGC

      private int counterGC
      DOCUMENT ME!
    • listenerList

      private EventListenerList listenerList
      DOCUMENT ME!
    • percentage

      private int percentage
      DOCUMENT ME!
    • sleepAmount

      private long sleepAmount
      DOCUMENT ME!
    • thread

      private volatile Thread thread
      DOCUMENT ME!
    • usedMemory

      private float usedMemory
      DOCUMENT ME!
    • freeMemory

      private float freeMemory
      DOCUMENT ME!
    • totalMemory

      private float totalMemory
      DOCUMENT ME!
  • Constructor Details

    • MemoryMonitor

      public MemoryMonitor()
      Constructor. Creates the list for listeners
  • Method Details

    • addMemoryChangeListener

      public void addMemoryChangeListener(ChangeListener l)
      add a memory change listener.
      Parameters:
      l - DOCUMENT ME!
    • focusGained

      public void focusGained(FocusEvent fe)
      focus gained.
      Specified by:
      focusGained in interface FocusListener
      Parameters:
      fe - DOCUMENT ME!
    • focusLost

      public void focusLost(FocusEvent fe)
      when focus is lost the source is assumed to be a JTextField, and it sets the sample period.
      Specified by:
      focusLost in interface FocusListener
      Parameters:
      fe - DOCUMENT ME!
    • getFree

      public long getFree()
      The amount of free memory the thread found.
      Returns:
      free memory in bytes
    • getPercentage

      public int getPercentage()
      The percentage of used memory to total memory the thread found.
      Returns:
      percent of used memory to total memeory in %
    • getTotal

      public long getTotal()
      The amount of total memory the thread found.
      Returns:
      total memory allocated by the JVM in bytes
    • getUsed

      public long getUsed()
      The amount of used memory the thread found.
      Returns:
      used memory in bytes
    • removeMemoryChangeListener

      public void removeMemoryChangeListener(ChangeListener l)
      removes the change listener.
      Parameters:
      l - DOCUMENT ME!
    • run

      public void run()
      when the thread wakes up, it collects information from the runtime on current memory status. It then notifies all listeners.
      Specified by:
      run in interface Runnable
    • start

      public void start()
      Start the thread as a minimum priority thread.
    • stop

      public void stop()
      kill the thread.
    • fireMemoryChanged

      protected void fireMemoryChanged()
      Notify all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.