BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Memory Status / determine virtual memory usage of a process

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API)
View previous topic :: View next topic  
Author Message
Uli
Guest





PostPosted: Thu Oct 05, 2006 6:07 pm    Post subject: Memory Status / determine virtual memory usage of a process Reply with quote



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





PostPosted: Fri Oct 06, 2006 12:22 am    Post subject: Re: Memory Status / determine virtual memory usage of a proc Reply with quote



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





PostPosted: Fri Oct 06, 2006 8:10 am    Post subject: Re: Memory Status / determine virtual memory usage of a proc Reply with 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...
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





PostPosted: Fri Feb 23, 2007 12:36 am    Post subject: Re: Memory Status / determine virtual memory usage of a proc Reply with quote

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





PostPosted: Thu Apr 19, 2007 2:20 pm    Post subject: Re: Memory Status / determine virtual memory usage of a proc Reply with quote

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





PostPosted: Thu Apr 19, 2007 7:09 pm    Post subject: Re: Memory Status / determine virtual memory usage of a proc Reply with quote

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





PostPosted: Thu Apr 26, 2007 2:01 am    Post subject: Re: Memory Status / determine virtual memory usage of a proc Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.