 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Uli Guest
|
Posted: Thu Oct 05, 2006 6:07 pm Post subject: Memory Status / determine virtual memory usage of a process |
|
|
Hello,
is there a way to determine the memory-status of a specific process in the
way TaskManager does it? That means retrieving the amount of physical and
virtual memory usage.
I played around with the Toolhelp functions in conjunction with
Heap32ListFirst/Heap32ListNext and Heap32First/Heap32Next but however, the
calculated amount of memory usage based on these functions (adding up the
portions of LF32_FIXED / LF32_FREE / LF32_MOVABLE) does not fit to the
values shown in TaskManager. Additionally there's no way to distinguish
between physical and virtual memory chunks when using these functions. Also
the iteration through all the heap-chunks seems to be rather slow ...
So, is there a better and more reliable way to do this? (Where does
TaskManager get the information from?)
Thanks,
Uli. |
|
| Back to top |
|
 |
Bob Gonder Guest
|
Posted: Fri Oct 06, 2006 12:22 am Post subject: Re: Memory Status / determine virtual memory usage of a proc |
|
|
Uli wrote:
| Quote: | is there a way to determine the memory-status of a specific process in the
way TaskManager does it? That means retrieving the amount of physical and
virtual memory usage.
|
Are you looking for GlobalMemoryStatus() ? |
|
| Back to top |
|
 |
Uli Guest
|
Posted: Fri Oct 06, 2006 8:10 am Post subject: Re: Memory Status / determine virtual memory usage of a proc |
|
|
No. I know about the GlobalMemoryStatus() function.
As I wrote, I want to determine the memory status (usage) of a specific
process in a fast way programatically. I want (respectively I expect) to get
the same values which are shown in Windows TaskManager in the tab-sheet
"Processes".
"Bob Gonder" <notbg (AT) notmindspring (DOT) invalid> schrieb im Newsbeitrag
news:opmai2t3e9fes14t37l55mbrea9si9rans (AT) 4ax (DOT) com...
| Quote: | Uli wrote:
is there a way to determine the memory-status of a specific process in the
way TaskManager does it? That means retrieving the amount of physical and
virtual memory usage.
Are you looking for GlobalMemoryStatus() ?
|
|
|
| Back to top |
|
 |
Sam S. Firouz Guest
|
Posted: Fri Feb 23, 2007 12:36 am Post subject: Re: Memory Status / determine virtual memory usage of a proc |
|
|
Check out the GetProcessMemoryInfo API.
Sam
"Uli" <nospam (AT) nospam (DOT) de> wrote in message
news:4525f6e8 (AT) newsgroups (DOT) borland.com...
| Quote: | No. I know about the GlobalMemoryStatus() function.
As I wrote, I want to determine the memory status (usage) of a specific
process in a fast way programatically. I want (respectively I expect) to
get the same values which are shown in Windows TaskManager in the
tab-sheet "Processes".
"Bob Gonder" <notbg (AT) notmindspring (DOT) invalid> schrieb im Newsbeitrag
news:opmai2t3e9fes14t37l55mbrea9si9rans (AT) 4ax (DOT) com...
Uli wrote:
is there a way to determine the memory-status of a specific process in
the
way TaskManager does it? That means retrieving the amount of physical and
virtual memory usage.
Are you looking for GlobalMemoryStatus() ?
|
|
|
| Back to top |
|
 |
ADC GmbH Guest
|
Posted: Thu Apr 19, 2007 2:20 pm Post subject: Re: Memory Status / determine virtual memory usage of a proc |
|
|
Sam S. Firouz schrieb:
| Quote: | Check out the GetProcessMemoryInfo API.
Sam
"Uli" <nospam (AT) nospam (DOT) de> wrote in message
news:4525f6e8 (AT) newsgroups (DOT) borland.com...
No. I know about the GlobalMemoryStatus() function.
As I wrote, I want to determine the memory status (usage) of a
specific process in a fast way programatically. I want (respectively I
expect) to get the same values which are shown in Windows TaskManager
in the tab-sheet "Processes".
"Bob Gonder" <notbg (AT) notmindspring (DOT) invalid> schrieb im Newsbeitrag
news:opmai2t3e9fes14t37l55mbrea9si9rans (AT) 4ax (DOT) com...
Uli wrote:
is there a way to determine the memory-status of a specific process
in the
way TaskManager does it? That means retrieving the amount of
physical and
virtual memory usage.
Are you looking for GlobalMemoryStatus() ?
I have the same problem and I tried to use the following code: |
PROCESS_MEMORY_COUNTERS lMemInfo;
HANDLE lProcHandle;
DWORD lProcID = GetProcessId(Application->Handle);
lProcHandle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
false, lProcID );
GetProcessMemoryInfo(lProcHandle, &lMemInfo, sizeof(lMemInfo));
CloseHandle(lProcHandle);
It fails because the GetProcessId return NULL (what handle do I have to
use) and the second problem is that I don't know which values of the
result structure I have to use (e.g. adding for the correct memory usage).
Has anybody a code example?
Thanks, Soeren |
|
| Back to top |
|
 |
Bob Gonder Guest
|
Posted: Thu Apr 19, 2007 7:09 pm Post subject: Re: Memory Status / determine virtual memory usage of a proc |
|
|
ADC GmbH wrote:
| Quote: | I have the same problem and I tried to use the following code:
PROCESS_MEMORY_COUNTERS lMemInfo;
HANDLE lProcHandle;
DWORD lProcID = GetProcessId(Application->Handle);
It fails because the GetProcessId return NULL (what handle do I have to
use)
|
Try using GetCurrentProcessId() instead.
| Quote: | lProcHandle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
false, lProcID );
GetProcessMemoryInfo(lProcHandle, &lMemInfo, sizeof(lMemInfo));
CloseHandle(lProcHandle);
|
And try simplifing it altogether:
PROCESS_MEMORY_COUNTERS lMemInfo;
GetProcessMemoryInfo( GetCurrentProcess(),
&lMemInfo, sizeof(lMemInfo));
| Quote: | and the second problem is that I don't know which values of the
result structure I have to use (e.g. adding for the correct memory usage).
|
Depends on what exactly you want to know.
See "Process Memory Usage Information" in the BDS Help. |
|
| Back to top |
|
 |
ADC GmbH Guest
|
Posted: Thu Apr 26, 2007 2:01 am Post subject: Re: Memory Status / determine virtual memory usage of a proc |
|
|
Bob Gonder schrieb:
| Quote: | ADC GmbH wrote:
I have the same problem and I tried to use the following code:
PROCESS_MEMORY_COUNTERS lMemInfo;
HANDLE lProcHandle;
DWORD lProcID = GetProcessId(Application->Handle);
It fails because the GetProcessId return NULL (what handle do I have to
use)
Try using GetCurrentProcessId() instead.
lProcHandle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
false, lProcID );
GetProcessMemoryInfo(lProcHandle, &lMemInfo, sizeof(lMemInfo));
CloseHandle(lProcHandle);
And try simplifing it altogether:
PROCESS_MEMORY_COUNTERS lMemInfo;
GetProcessMemoryInfo( GetCurrentProcess(),
&lMemInfo, sizeof(lMemInfo));
and the second problem is that I don't know which values of the
result structure I have to use (e.g. adding for the correct memory usage).
Depends on what exactly you want to know.
See "Process Memory Usage Information" in the BDS Help.
Your code works fine, this is exactly what I needed. Thank you very much! |
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|