Package gov.nih.mipav.view
Class ViewJFrameMemory.MemoryMonitor
- java.lang.Object
-
- gov.nih.mipav.view.ViewJFrameMemory.MemoryMonitor
-
- All Implemented Interfaces:
java.awt.event.FocusListener,java.lang.Runnable,java.util.EventListener
- Enclosing class:
- ViewJFrameMemory
public class ViewJFrameMemory.MemoryMonitor extends java.lang.Object implements java.lang.Runnable, java.awt.event.FocusListenerTracks Memory allocated & used, and notifies anybody who is interested in finding out about it.
-
-
Field Summary
Fields Modifier and Type Field Description private javax.swing.event.ChangeEventchangeEventDOCUMENT ME!private intcounterGCDOCUMENT ME!private floatfreeMemoryDOCUMENT ME!private javax.swing.event.EventListenerListlistenerListDOCUMENT ME!private intpercentageDOCUMENT ME!private longsleepAmountDOCUMENT ME!private java.lang.ThreadthreadDOCUMENT ME!private floattotalMemoryDOCUMENT ME!private floatusedMemoryDOCUMENT ME!
-
Constructor Summary
Constructors Constructor Description MemoryMonitor()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMemoryChangeListener(javax.swing.event.ChangeListener l)add a memory change listener.protected voidfireMemoryChanged()Notify all listeners that have registered interest for notification on this event type.voidfocusGained(java.awt.event.FocusEvent fe)focus gained.voidfocusLost(java.awt.event.FocusEvent fe)when focus is lost the source is assumed to be a JTextField, and it sets the sample period.longgetFree()The amount of free memory the thread found.intgetPercentage()The percentage of used memory to total memory the thread found.longgetTotal()The amount of total memory the thread found.longgetUsed()The amount of used memory the thread found.voidremoveMemoryChangeListener(javax.swing.event.ChangeListener l)removes the change listener.voidrun()when the thread wakes up, it collects information from the runtime on current memory status.voidstart()Start the thread as a minimum priority thread.voidstop()kill the thread.
-
-
-
Field Detail
-
changeEvent
private javax.swing.event.ChangeEvent changeEvent
DOCUMENT ME!
-
counterGC
private int counterGC
DOCUMENT ME!
-
listenerList
private javax.swing.event.EventListenerList listenerList
DOCUMENT ME!
-
percentage
private int percentage
DOCUMENT ME!
-
sleepAmount
private long sleepAmount
DOCUMENT ME!
-
thread
private volatile java.lang.Thread thread
DOCUMENT ME!
-
usedMemory
private float usedMemory
DOCUMENT ME!
-
freeMemory
private float freeMemory
DOCUMENT ME!
-
totalMemory
private float totalMemory
DOCUMENT ME!
-
-
Method Detail
-
addMemoryChangeListener
public void addMemoryChangeListener(javax.swing.event.ChangeListener l)
add a memory change listener.- Parameters:
l- DOCUMENT ME!
-
focusGained
public void focusGained(java.awt.event.FocusEvent fe)
focus gained.- Specified by:
focusGainedin interfacejava.awt.event.FocusListener- Parameters:
fe- DOCUMENT ME!
-
focusLost
public void focusLost(java.awt.event.FocusEvent fe)
when focus is lost the source is assumed to be a JTextField, and it sets the sample period.- Specified by:
focusLostin interfacejava.awt.event.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(javax.swing.event.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:
runin interfacejava.lang.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.
-
-