Tracking dynamic memory usage in my program



In my program, which iterates over a loop many thousands of times, allocating and deallocating memory, I want to track dynamic memory allocation. I am doing this because Task Manager shows increasing memory each time through the loop and this does not appear to correspond to what I am doing in the loop. To track dynamic memory programatically I am using a routine that cycles through all the heaps and reports back the total allocated memory, the total committed memory, and the total uncomitted memory for all heaps. The routines uses GetProcessHeap, GetProcessHeaps and HeapWalk.

I am also checking the Task Manager in Win2k while I debug my application and look at the results. What I have seen that puzzles me is that the totals shown by Task Manager do not at all correspond to what my routines show for the memory totals I am picking up from HeapWalk. Task manager is showing a steady increase through each loop while my memory tracking routine is showing a much smaller difference in each loop, the latter corresponding much more closely to what I believe I am actually allocating and deallocating for each loop ( I am holding on to some of the data during each loop for further processing when the loop is finished, then releasing the data.

Am I doing something wrong in tracking my dynamic memory usage using heaps and HeapWalk ? Is there a better, easier way which corresponds to what Task Manager is reporting ? Why would not HeapWalk be reporting the correct amounts ?

The HeapWalk routines I am using are from http://www.codeguru.com/Cpp/W-P/win32/tutorials/article.php/c9495/ and look good to me. I have created a DLL from these routines, after changing them to do what I want, and exported the necessary functions which I am using in my program. I could be wrong but I do not think the problem is with any of this code.
.




Relevant Pages

  • Re: Tracking dynamic memory usage in my program
    ... Task Manager shows working set size not VM usage by default. ... > allocating and deallocating memory, I want to track dynamic memory ... > each time through the loop and this does not appear to correspond to what ... The routines uses GetProcessHeap, GetProcessHeaps ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Fast string operations
    ... > is why people use unsafe code now and then to use pointer arithmetic to ... > loop over arrays without all the unnecessary bounds checking. ... don't return the trimmed string". ... The customer perceives this as a memory leak. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Performance Improvement of complex data structure (hash of hashes of hashes)
    ... Anno Siegel wrote: ... >> Here is the code that I'm using to build up this data structure. ... loop through and increment the ... I know that memory allocation in C is expensive, ...
    (comp.lang.perl.misc)
  • Re: Cost of calling a standard library function
    ... It accesses/reads memory using esi 4 ... > safly move it within the cache, without having to go via ebx. ... try it the same thing on a different earlier CPU, ... should check it out...for "tight inner loop" stuff, ...
    (alt.lang.asm)
  • Re: Restoring a NorthStar Horizon, problems with SRAM board
    ... A-D FDC is a memory mapped IO device so I would expect some behavior ... loop read/write functions - which puts the system into a two instruction ... SRAM on the Vector Graphics Flashwriter video card located at $F000 ...
    (comp.sys.northstar)