🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

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

#2052
From: ADC GmbH
Date: Wed, 25 Apr 2007 21:01
33 lines
2171 bytes
Bob Gonder schrieb:
> 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!
Technical Details
Message-ID: <462fc27a@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!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> <462734d9$1@newsgroups.borland.com> <gnse23pehr8v3mpnht06t652gd7fretebt@4ax.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: Wed, 25 Apr 2007 23:01:39 +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> <462734d9$1@newsgroups.borland.com> <gnse23pehr8v3mpnht06t652gd7fretebt@4ax.com>
In-Reply-To: <gnse23pehr8v3mpnht06t652gd7fretebt@4ax.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 62.153.221.162
Message-ID: <462fc27a@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1177535098 62.153.221.162 (25 Apr 2007 14:04:58 -0700)
Lines: 33
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail