Re: Getting Peak Commit from NtQuerySystemInformation

Thomas Heller <[email protected]>
Newsgroups gmane.comp.python.ctypes
Message-ID <[email protected]>
Mike Driscoll schrieb:
> On 3/4/2010 1:22 AM, Thomas Heller wrote:
>> Mike Driscoll schrieb:
>>    
>>> Hi Thomas,
>>>
>>> On 3/3/2010 3:14 AM, Thomas Heller wrote:
>>>      
>> [...]
>>    
>>> When I run this on my machine, it gives me 368456 as the result, whereas
>>> Task Manager give me 1473824. Stupid question, but do I need to convert
>>> the long to a kilobyte or something?  I tried, but that was way off, so
>>> I must be doing something wrong. Thank you for your help!
>>>      
>> Mike, I said this snippet is not really tested.
>> I created the definition of the SYSTEM_PERFORMANCE_INFORMATION
>> structure from some sample C++ code I found on the internet;
>> it may be wrong, it may be that I made a mistake or whatever.
>>
>> You have to do some research:  Find out the real definition of this structure,
>> (I don't known if it is in some MS header file), you have to compare it to my code,
>> you have to find out what the field contents really means: kilobyte, pages, or whatever.
>>
>>    
> 
> Sorry...I did do some research, but MSDN is confusing. According to this 
> page, http://msdn.microsoft.com/en-us/library/ms724509%28VS.85%29.aspx, 
> SystemPerformanceInformation "returns an opaque 
> *SYSTEM_PERFORMANCE_INFORMATION* structure that can be used to generate 
> an unpredictable seed for a random number generator. Use the 
> *CryptGenRandom* 
> <http://msdn.microsoft.com/en-us/library/aa379942%28VS.85%29.aspx> 
> function instead."
> 
> My understanding of that sentence is that it's just a randomization seed 
> function that may or may not return the same number. The struct 
> definition looks like this:
> 
> |typedef struct _SYSTEM_PERFORMANCE_INFORMATION {
>      BYTE Reserved1[312];
> } SYSTEM_PERFORMANCE_INFORMATION;|
> 

It simply means that the structure exposes internal information which is not
published officially.

Well, I ran my script again, and changed the final print statement to this:

print spi.PeakCommitment * 4096 / 1024

Now it print '2310636', which is exactly the same value as sysinternals process monitor
shows in its 'System Information' dialog as 'Peak Commit Charge (K)'
so I assume it is correct: spi.PeakCommitment returns the peak number of committed
memory pages, each page (on the x86 at least) has 4096 bytes so we multiply by 4096,
then we divide by 1024 to get the value in KB.

Looks good, if you ask me.

> 
> Thanks for your help. I apologize for bothering you.

No problem - you're welcome.

-- 
Thanks,
Thomas


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.