How determine where "virtual size" is being used?

Giganews Newsgroups
Subject: How determine where "virtual size" is being used?
Posted by:  Chris Shearer Cooper (chris_w…@sc3.net)
Date: Thu, 27 Mar 2008

My MFC application has some strange behavior ... as it runs, the "virtual
size" as reported by Process Manager slowly grows to a ridiculous size,
while the "working set" stays relatively constant.  When I exit the
application, MFC's built-in memory leak detection says I'm not leaking
memory anywhere.  However, I absolutely realize the limitations of the MFC
memory leak stuff.

The application does a lot of creating of threads and communication with an
in-process COM object, so I can see lots of places where memory could be
allocated where MFC wouldn't know about it.  I am very careful to let my
threads finish normally (no killing threads off prematurely).

Is there a programmatic way to enumerate the pages that are contributing to
the "virtual size"?  Some way I can have my program spit out a list of what
memory blocks are being used, where/when they were allocated (and by which
thread), that sort of information?

The company isn't thrilled about the idea of buying one of the commercial
products for detecting memory leaks, but if that really is the answer I can
push them on it.

Thanks,
Chris

Replies