Copyright 2009,2010, Lapetus Systems Ltd. (All rights reserved)

com.lapetus_ltd.api.common
Class TLptsMemoryInfo

java.lang.Object
  extended by com.lapetus_ltd.api.common.TLptsMemoryInfo

public class TLptsMemoryInfo
extends java.lang.Object

Class Description : This is a class made for monitoring the memory.

Instantiate this class every time you want to create a new 'snapshot' of the memory for the current application.
These 'snapshots' can be kept in a list or refreshed on the GUI for keeping track of the memory situation.

The toolbox can be used for instantiating with TLptsSysInfoUtil.getMemoryInfo().

$LastChangedRevision: 1182 $
$LastChangedDate:: 2010-11-15 16:01:51#$


Constructor Summary
TLptsMemoryInfo()
           Default Constructor sets the current system total, maximum and free memory in MBytes.
 
Method Summary
 double getFreeMemoryInMb()
           Get Application Free Memory in MBytes.
 double getMaxMemoryInMb()
           Get Application Max Memory.
 java.lang.String getMemoryString(double value, java.lang.String format)
           Formats the string for output on the GUI.
 long getTime()
           Get Current DateTime in long format.
 java.lang.String getTimeString()
           Gets the timestamp at the time of the memory information.
 double getTotalMemoryInMb()
           Get application total memory in MBytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TLptsMemoryInfo

public TLptsMemoryInfo()

Default Constructor sets the current system total, maximum and free memory in MBytes.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : N/A

Notes :

Example :


 public void actionPerformed(ActionEvent e)
 {
   TLptsMemoryInfo mi = new TLptsMemoryInfo();
   String maxMemory = mi.getMemoryString(mi.getMaxMemoryInMb(), "#####.0000");
   String totalMemory = mi.getMemoryString(mi.getTotalMemoryInMb(), "#####.0000");
   String freeMemory = mi.getMemoryString(mi.getFreeMemoryInMb(), "#####.0000");
   Timestamp dateTime = new Timestamp(mi.getTime());
   //Or
   String time  = mi.getTimeString();
 }

 Result:63,5625
        4,9375
        4,3906
        2010-07-08 10:58:55.493
        10:58:55.493

 

Method Detail

getFreeMemoryInMb

public double getFreeMemoryInMb()

Get Application Free Memory in MBytes.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : No

Notes :

Example :


 public void actionPerformed(ActionEvent e)
 {
   TLptsMemoryInfo mi = new TLptsMemoryInfo();
   String maxMemory = mi.getMemoryString(mi.getMaxMemoryInMb(), "#####.0000");
   String totalMemory = mi.getMemoryString(mi.getTotalMemoryInMb(), "#####.0000");
   String freeMemory = mi.getMemoryString(mi.getFreeMemoryInMb(), "#####.0000");
   Timestamp dateTime = new Timestamp(mi.getTime());
   //Or
   String time  = mi.getTimeString();
 }

 Result:63,5625
        4,9375
        4,3906
        2010-07-08 10:58:55.493
        10:58:55.493
 

Returns:
free memory

getMaxMemoryInMb

public double getMaxMemoryInMb()

Get Application Max Memory.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : No

Notes :

Example :


 public void actionPerformed(ActionEvent e)
 {
   TLptsMemoryInfo mi = new TLptsMemoryInfo();
   String maxMemory = mi.getMemoryString(mi.getMaxMemoryInMb(), "#####.0000");
   String totalMemory = mi.getMemoryString(mi.getTotalMemoryInMb(), "#####.0000");
   String freeMemory = mi.getMemoryString(mi.getFreeMemoryInMb(), "#####.0000");
   Timestamp dateTime = new Timestamp(mi.getTime());
   //Or
   String time  = mi.getTimeString();
 }

 Result:63,5625
        4,9375
        4,3906
        2010-07-08 10:58:55.493
        10:58:55.493
 

Returns:
max memory

getMemoryString

public java.lang.String getMemoryString(double value,
                                        java.lang.String format)

Formats the string for output on the GUI.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : N/A

Notes :

Example :


 public void actionPerformed(ActionEvent e)
 {
   TLptsMemoryInfo mi = new TLptsMemoryInfo();
   String maxMemory = mi.getMemoryString(mi.getMaxMemoryInMb(), "#####.0000");
   String totalMemory = mi.getMemoryString(mi.getTotalMemoryInMb(), "#####.0000");
   String freeMemory = mi.getMemoryString(mi.getFreeMemoryInMb(), "#####.0000");
   Timestamp dateTime = new Timestamp(mi.getTime());
   //Or
   String time  = mi.getTimeString();
 }

 Result:63,5625
        4,9375
        4,3906
        2010-07-08 10:58:55.493
        10:58:55.493
   * 

Parameters:
value - The value to format into a string.
format - 0000.0000 = 0123.1230, #####.#### = 123.123.
Returns:
Returns the formatted string.

getTime

public long getTime()

Get Current DateTime in long format.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : No

Notes :

Example :


 public void actionPerformed(ActionEvent e)
 {
   TLptsMemoryInfo mi = new TLptsMemoryInfo();
   String maxMemory = mi.getMemoryString(mi.getMaxMemoryInMb(), "#####.0000");
   String totalMemory = mi.getMemoryString(mi.getTotalMemoryInMb(), "#####.0000");
   String freeMemory = mi.getMemoryString(mi.getFreeMemoryInMb(), "#####.0000");
   Timestamp dateTime = new Timestamp(mi.getTime());
   //Or
   String time  = mi.getTimeString();
 }

 Result:63,5625
        4,9375
        4,3906
        2010-07-08 10:58:55.493
        10:58:55.493
   * 

Returns:
current dateTime

getTimeString

public java.lang.String getTimeString()

Gets the timestamp at the time of the memory information.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : N/A

Notes :

Example :


 public void actionPerformed(ActionEvent e)
 {
   TLptsMemoryInfo mi = new TLptsMemoryInfo();
   String maxMemory = mi.getMemoryString(mi.getMaxMemoryInMb(), "#####.0000");
   String totalMemory = mi.getMemoryString(mi.getTotalMemoryInMb(), "#####.0000");
   String freeMemory = mi.getMemoryString(mi.getFreeMemoryInMb(), "#####.0000");
   Timestamp dateTime = new Timestamp(mi.getTime());
   //Or
   String time  = mi.getTimeString();
 }

 Result:63,5625
        4,9375
        4,3906
        2010-07-08 10:58:55.493
        10:58:55.493
   * 

Returns:
The string of format hh:mm:ss.sss

getTotalMemoryInMb

public double getTotalMemoryInMb()

Get application total memory in MBytes.

Thread Safe : Yes

Spawns its own Thread : No

May Return NULL : No

Notes :

Example :


 public void actionPerformed(ActionEvent e)
 {
   TLptsMemoryInfo mi = new TLptsMemoryInfo();
   String maxMemory = mi.getMemoryString(mi.getMaxMemoryInMb(), "#####.0000");
   String totalMemory = mi.getMemoryString(mi.getTotalMemoryInMb(), "#####.0000");
   String freeMemory = mi.getMemoryString(mi.getFreeMemoryInMb(), "#####.0000");
   Timestamp dateTime = new Timestamp(mi.getTime());
   //Or
   String time  = mi.getTimeString();
 }

 Result:63,5625
        4,9375
        4,3906
        2010-07-08 10:58:55.493
        10:58:55.493

 

Returns:
total memory


Copyright 2009,2010, Lapetus Systems Ltd. (All rights reserved)