• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • Last Modified:

physical memory based

hi
how can i know which running process holds how much physical memory
right now.how can i write the code which will detect the memory usage
of a running process.please help me.


thanks in advance
0
davinder101
Asked:
davinder101
2 Solutions
 
seopherCommented:
i think you'll be looking at Jconsole for this:

http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html

It's not something i've ever attempted so i'm not sure of how feasible it is, but Jconsole seems the trick (to begin with anyway).

Steve
0
 
wnrossCommented:
(Windows)
pview.exe (Part of platform SDK tools) will give you any breakdowns you require.  Programatically you can use C# and the System.Diagonistics package

// Get all processes in 'proc' array
Diagnostics::Process *p[]=Diagnostics::Process::GetProcesses();

// Run through all processes
for(int n=proc->GetLength(0),i=0; i < n; i++) {
  Console::Write(proc[i]->ProcessName);  Console::Write("\t");
    // Name of the process (no extension)
  Console::Write(proc[i]->Threads->Count);
    // Number of threads
  Console::Write("\t");  Console::Write(proc[i]->HandleCount);
    // Number of handles

  /*System::TimeSpan ts=proc[i]->TotalProcessorTime;
  sprintf(s,"%02d:%02d:%02d",ts.Hours,ts.Minutes,ts.Seconds);*/

  Console::WriteLine(proc[i]->MainWindowTitle);
    // Title of main window - null if no UI
}
You will also want to look at ProcessThread and ProcessThreadCollection classes


(Linux)
Each process can be explored via the /proc/ filesystem, including memory stats.
[root@streams1 pam.d]# ls /proc/21284/ -l
total 0
-r--r--r--    1 root     root            0 May  1 12:42 cmdline
lrwxrwxrwx    1 root     root            0 May  1 12:42 cwd -> /etc/pam.d
-r--------    1 root     root            0 May  1 12:42 environ
lrwxrwxrwx    1 root     root            0 May  1 12:42 exe -> /bin/bash
dr-x------    2 root     root            0 May  1 12:42 fd
-r--r-----    1 root     root            0 May  1 12:42 maps
-rw-------    1 root     root            0 May  1 12:42 mem
-r--r--r--    1 root     root            0 May  1 12:42 mounts
lrwxrwxrwx    1 root     root            0 May  1 12:42 root -> /
-r--r--r--    1 root     root            0 May  1 12:42 stat
-r--r--r--    1 root     root            0 May  1 12:42 statm
-r--r--r--    1 root     root            0 May  1 12:42 status

Cheers,
-Bill
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now