🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #2168

Re: Memory Status / determine virtual memory usage of a process

#2168
From: ADC GmbH
Date: Thu, 19 Apr 2007 09:20
49 lines
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
Technical Details
Message-ID: <462734d9$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <45250397@newsgroups.borland.com> <opmai2t3e9fes14t37l55mbrea9si9rans@4ax.com> <4525f6e8@newsgroups.borland.com> <45dde3ad$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,aba0bbbda094b5c8
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Thu, 19 Apr 2007 11:20:35 +0200
From: ADC GmbH <ew@adcgmbh.de>
User-Agent: Thunderbird 1.5.0.8 (Windows/20061025)
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Memory Status / determine virtual memory usage of a process
References: <45250397@newsgroups.borland.com> <opmai2t3e9fes14t37l55mbrea9si9rans@4ax.com> <4525f6e8@newsgroups.borland.com> <45dde3ad$1@newsgroups.borland.com>
In-Reply-To: <45dde3ad$1@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 62.153.221.162
Message-ID: <462734d9$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1176974553 62.153.221.162 (19 Apr 2007 02:22:33 -0800)
Lines: 51
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail