Re: Monitoring RAM
Re: Monitoring RAM
- Subject: Re: Monitoring RAM
- From: Chuck Hill <email@hidden>
- Date: Fri, 22 Sep 2006 13:38:26 -0700
Hi Owen,
On Sep 21, 2006, at 3:40 PM, Owen McKerrow wrote:
Hi There,
I set up my app to run over night and see what happened to its RAM
and noticed something strange when I came in this morning.
All night there was 0 active sessions ( expected ) but the RAM
would fluctuate between 47 MEG and 50 MEG over a period of a couple
of minutes.
That may be the result of incoming requests from wotaskd.
I then went to the page, thus creating a new session and the RAM
used dropped by 6 MEG. Another couple of sessions and it dropped a
bit further, with finally after 7 session it was down by 10 MEG.
That is perhaps not unexpected. When the last sessions expired, the
memory they used was eligible for reclamation by the GC. The memory
was not needed until you created new sessions so the GC did nothing.
So before i go any further with my testing and questions for you
guys I thought I should get my code double checked in regards to
how Im reading this RAM
I think you are reading it correctly. More in the code below...
So heres a grab of the output this moring just before and after I
made my sessions
08:32:16,257 OFF [Timer-1] (Log.NSLogOut:1546 appendln) - Total
Mem : 63.0 MG
08:32:16,257 OFF [Timer-1] (Log.NSLogOut:1546 appendln) - Free
Mem : 14.0 MG
08:32:16,257 OFF [Timer-1] (Log.NSLogOut:1546 appendln) - Used :
49.0 MG
08:32:16,257 OFF [Timer-1] (Log.NSLogOut:1546 appendln) - Active
Sessions : 0
08:32:31,257 OFF [Timer-1] (Log.NSLogOut:1546 appendln) - Total
Mem : 63.0 MG
08:32:31,257 OFF [Timer-1] (Log.NSLogOut:1546 appendln) - Free
Mem : 14.0 MG
08:32:31,257 OFF [Timer-1] (Log.NSLogOut:1546 appendln) - Used :
49.0 MG
08:32:31,257 OFF [Timer-1] (Log.NSLogOut:1546 appendln) - Active
Sessions : 0
08:32:42,901 OFF [WorkerThread3] (Log.NSLogOut:1546 appendln) -
Session Created : 9KSkQ9FaSsLnfpoyzVpWug
08:32:46,256 OFF [Timer-1] (Log.NSLogOut:1546 appendln) - Total
Mem : 63.0 MG
08:32:46,257 OFF [Timer-1] (Log.NSLogOut:1546 appendln) - Free
Mem : 20.0 MG
08:32:46,257 OFF [Timer-1] (Log.NSLogOut:1546 appendln) - Used :
43.0 MG
08:32:46,257 OFF [Timer-1] (Log.NSLogOut:1546 appendln) - Active
Sessions : 1
08:33:00,405 OFF [WorkerThread3] (Log.NSLogOut:1546 appendln) -
Session Created : jxj7Lo4ui5vGB836bESL5w
08:33:01,256 OFF [Timer-1] (Log.NSLogOut:1546 appendln) - Total
Mem : 63.0 MG
08:33:01,257 OFF [Timer-1] (Log.NSLogOut:1546 appendln) - Free
Mem : 22.0 MG
08:33:01,257 OFF [Timer-1] (Log.NSLogOut:1546 appendln) - Used :
41.0 MG
08:33:01,257 OFF [Timer-1] (Log.NSLogOut:1546 appendln) - Active
Sessions : 2
08:33:04,739 OFF [WorkerThread3] (Log.NSLogOut:1546 appendln) -
Session Created : 1xt5mbejacNB80hFeXzaog
08:33:10,279 OFF [WorkerThread3] (Log.NSLogOut:1546 appendln) -
Session Created : zOPs95bCrNNtFpKqEBpfKM
08:33:14,493 OFF [WorkerThread3] (Log.NSLogOut:1546 appendln) -
Session Created : COs82ecQ3hiUZbxiwCnfOg
08:33:16,256 OFF [Timer-1] (Log.NSLogOut:1546 appendln) - Total
Mem : 63.0 MG
08:33:16,256 OFF [Timer-1] (Log.NSLogOut:1546 appendln) - Free
Mem : 25.0 MG
08:33:16,256 OFF [Timer-1] (Log.NSLogOut:1546 appendln) - Used :
38.0 MG
08:33:16,257 OFF [Timer-1] (Log.NSLogOut:1546 appendln) - Active
Sessions : 5
08:33:16,863 OFF [WorkerThread3] (Log.NSLogOut:1546 appendln) -
Session Created : ZyG7CBSnsBd8diFi3l5Vf0
08:33:29,397 OFF [WorkerThread3] (Log.NSLogOut:1546 appendln) -
Session Created : 7xi2ClgCGHCbDoSSt4bUJw
08:33:31,256 OFF [Timer-1] (Log.NSLogOut:1546 appendln) - Total
Mem : 63.0 MG
08:33:31,256 OFF [Timer-1] (Log.NSLogOut:1546 appendln) - Free
Mem : 25.0 MG
08:33:31,256 OFF [Timer-1] (Log.NSLogOut:1546 appendln) - Used :
38.0 MG
08:33:31,256 OFF [Timer-1] (Log.NSLogOut:1546 appendln) - Active
Sessions : 7
08:33:46,256 OFF [Timer-1] (Log.NSLogOut:1546 appendln) - Total
Mem : 63.0 MG
08:33:46,256 OFF [Timer-1] (Log.NSLogOut:1546 appendln) - Free
Mem : 25.0 MG
08:33:46,256 OFF [Timer-1] (Log.NSLogOut:1546 appendln) - Used :
38.0 MG
08:33:46,256 OFF [Timer-1] (Log.NSLogOut:1546 appendln) - Active
Sessions : 7
And heres the code, it set on a timer to run every 15 seconds. Im I
doing this correctly ?
public class MemoryWatch extends TimerTask
{
public RISApplication app;
public MemoryWatch(RISApplication newApp) {
app = newApp;
}
public void run()
{
try
{
Runtime runtime = Runtime.getRuntime();
You might want to try and strongly suggest a GC cycle here:
System.gc();
System.gc();
System.gc();
That may produce a more accurate accounting of free memory.
Chuck
long totalMem = runtime.totalMemory();
long freeMem = runtime.freeMemory();
double difference = new Double(((totalMem/1024)/1024) -
((freeMem/1024)/1024)).doubleValue();
NSLog.out.appendln("Total Mem : " + new Double(((totalMem/1024)/
1024)).doubleValue() + " MG");
NSLog.out.appendln("Free Mem : " + new Double(((freeMem/1024)/
1024)).doubleValue() + " MG");
NSLog.out.appendln("Used : " + difference + " MG");
NSLog.out.appendln("Active Sessions : " + app.activeSessionsCount
());
}
catch(Exception e)
{
NSLog.out.appendln("Error occured during the Memory Watch");
}
}
}
Owen McKerrow
WebMaster, emlab
Ph : +61 02 4221 5517
http://emlab.uow.edu.au
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - -
'The test of a first-rate intelligence is the ability to hold two
opposed ideas in the mind at the same time and still be able to
function.'
-F.Scott Fitzgerald,
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40global-village.net
This email sent to email@hidden
--
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems. http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden