Article View: borland.public.cppbuilder.nativeapi
Article #2169Re: Memory Status / determine virtual memory usage of a process
From: 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.
Technical Details
Message-ID:
<gnse23pehr8v3mpnht06t652gd7fretebt@4ax.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<45250397@newsgroups.borland.com> <opmai2t3e9fes14t37l55mbrea9si9rans@4ax.com> <4525f6e8@newsgroups.borland.com> <45dde3ad$1@newsgroups.borland.com> <462734d9$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 From: Bob Gonder <notbg@notmindspring.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Memory Status / determine virtual memory usage of a process Date: Thu, 19 Apr 2007 07:09:41 -0700 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <gnse23pehr8v3mpnht06t652gd7fretebt@4ax.com> References: <45250397@newsgroups.borland.com> <opmai2t3e9fes14t37l55mbrea9si9rans@4ax.com> <4525f6e8@newsgroups.borland.com> <45dde3ad$1@newsgroups.borland.com> <462734d9$1@newsgroups.borland.com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 69.69.80.210 X-Trace: newsgroups.borland.com 1176991779 69.69.80.210 (19 Apr 2007 07:09:39 -0800) Lines: 31 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail