Package gov.nih.mipav.view
Class ViewJFrameMemory.MemoryMonitor
java.lang.Object
gov.nih.mipav.view.ViewJFrameMemory.MemoryMonitor
- All Implemented Interfaces:
FocusListener,Runnable,EventListener
- Enclosing class:
ViewJFrameMemory
Tracks Memory allocated invalid input: '&' used, and notifies anybody who is interested in finding out about it.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ChangeEventDOCUMENT ME!private intDOCUMENT ME!private floatDOCUMENT ME!private EventListenerListDOCUMENT ME!private intDOCUMENT ME!private longDOCUMENT ME!private ThreadDOCUMENT ME!private floatDOCUMENT ME!private floatDOCUMENT ME! -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd a memory change listener.protected voidNotify all listeners that have registered interest for notification on this event type.voidfocus gained.voidfocusLost(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.intThe 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.voidremoves 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 Details
-
changeEvent
DOCUMENT ME! -
counterGC
private int counterGCDOCUMENT ME! -
listenerList
DOCUMENT ME! -
percentage
private int percentageDOCUMENT ME! -
sleepAmount
private long sleepAmountDOCUMENT ME! -
thread
DOCUMENT ME! -
usedMemory
private float usedMemoryDOCUMENT ME! -
freeMemory
private float freeMemoryDOCUMENT ME! -
totalMemory
private float totalMemoryDOCUMENT ME!
-
-
Constructor Details
-
MemoryMonitor
public MemoryMonitor()Constructor. Creates the list for listeners
-
-
Method Details
-
addMemoryChangeListener
add a memory change listener.- Parameters:
l- DOCUMENT ME!
-
focusGained
focus gained.- Specified by:
focusGainedin interfaceFocusListener- Parameters:
fe- DOCUMENT ME!
-
focusLost
when focus is lost the source is assumed to be a JTextField, and it sets the sample period.- Specified by:
focusLostin interfaceFocusListener- 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
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. -
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.
-