Thread View: borland.public.cppbuilder.nativeapi
6 messages
6 total messages
Started by Uli
Thu, 05 Oct 2006 13:07
Memory Status / determine virtual memory usage of a process
Author: Uli
Date: Thu, 05 Oct 2006 13:07
Date: Thu, 05 Oct 2006 13:07
19 lines
1768 bytes
1768 bytes
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.
Re: Memory Status / determine virtual memory usage of a process
Author: Bob Gonder
Date: Thu, 05 Oct 2006 19:22
Date: Thu, 05 Oct 2006 19:22
7 lines
1309 bytes
1309 bytes
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() ?
Re: Memory Status / determine virtual memory usage of a process
Author: Uli
Date: Fri, 06 Oct 2006 06:25
Date: Fri, 06 Oct 2006 06:25
18 lines
1684 bytes
1684 bytes
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@notmindspring.invalid> schrieb im Newsbeitrag news:opmai2t3e9fes14t37l55mbrea9si9rans@4ax.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() ? > >
Re: Memory Status / determine virtual memory usage of a process
Author: Sam S. Firouz
Date: Thu, 22 Feb 2007 18:36
Date: Thu, 22 Feb 2007 18:36
29 lines
2073 bytes
2073 bytes
Check out the GetProcessMemoryInfo API. Sam "Uli" <nospam@nospam.de> wrote in message news:4525f6e8@newsgroups.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@notmindspring.invalid> schrieb im Newsbeitrag > news:opmai2t3e9fes14t37l55mbrea9si9rans@4ax.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() ? >> >> > >
Re: Memory Status / determine virtual memory usage of a process
Author: ADC GmbH
Date: Thu, 19 Apr 2007 09:20
Date: Thu, 19 Apr 2007 09:20
49 lines
2641 bytes
2641 bytes
Sam S. Firouz schrieb: > Check out the GetProcessMemoryInfo API. > > Sam > > > > "Uli" <nospam@nospam.de> wrote in message > news:4525f6e8@newsgroups.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@notmindspring.invalid> schrieb im Newsbeitrag >> news:opmai2t3e9fes14t37l55mbrea9si9rans@4ax.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
Re: Memory Status / determine virtual memory usage of a process
Author: Bob Gonder
Date: Thu, 19 Apr 2007 14:09
Date: Thu, 19 Apr 2007 14:09
29 lines
2069 bytes
2069 bytes
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.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads