views:

664

answers:

1

I am continuing my saga to understand memory consumption by VB6 application. The option that seems to work best so far is to monitor various memory metrics at key points at run-time and understand where big memory hogs are. The measure driver to study this, is to understand how the application scalability in multi-user environment in Terminal Server (Citrix) is impacted due to changes in memory consumption (in simple terms more memory you use, less users you can fit on the server).

I can get most memory metrics for the process using GetProcessMemoryInfo. Process Explorer reports additional metrics WS Private, WS Shareable, WS Shared - which seem very interesting for my investigation.

So question is, is there standard/hidden API to get these metric for a process? I would like to query these metrics programatically, so that I can capture them at key spots during application run and understand memory usage better.

+1  A: 

See the QueryWorkingSet API. This looks rather nasty to use though, as it returns info on a per-page basis and would therefore leave it up to you to aggregate the totals. If there's a better method, please leave a comment and I'll delete this answer.

Also, if you have specific places in mind where you want to monitor changes in the working set, you might want to check out the InitializeProcessForWsWatch and GetWsChanges APIs -- these might make it easier to see how many pages have been faulted in rather than having to walk the entire page set before and after.

itowlson