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.FocusListener
Tracks 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.ChangeEvent
changeEvent
DOCUMENT ME!private int
counterGC
DOCUMENT ME!private float
freeMemory
DOCUMENT ME!private javax.swing.event.EventListenerList
listenerList
DOCUMENT ME!private int
percentage
DOCUMENT ME!private long
sleepAmount
DOCUMENT ME!private java.lang.Thread
thread
DOCUMENT ME!private float
totalMemory
DOCUMENT ME!private float
usedMemory
DOCUMENT ME!
-
Constructor Summary
Constructors Constructor Description MemoryMonitor()
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMemoryChangeListener(javax.swing.event.ChangeListener l)
add a memory change listener.protected void
fireMemoryChanged()
Notify all listeners that have registered interest for notification on this event type.void
focusGained(java.awt.event.FocusEvent fe)
focus gained.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.long
getFree()
The amount of free memory the thread found.int
getPercentage()
The percentage of used memory to total memory the thread found.long
getTotal()
The amount of total memory the thread found.long
getUsed()
The amount of used memory the thread found.void
removeMemoryChangeListener(javax.swing.event.ChangeListener l)
removes the change listener.void
run()
when the thread wakes up, it collects information from the runtime on current memory status.void
start()
Start the thread as a minimum priority thread.void
stop()
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:
focusGained
in 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:
focusLost
in 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:
run
in 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.
-
-