Archived Forum Post

Index of archived forum posts

Question:

Find out C++ Memory Usage in Code?

Dec 15 '16 at 10:00

Does you C++ implementation have a tool to ask the current memory usage by you components?

I have a situation where I fetch about 1 MB of data from a database and feed it into the CkEmail component.

This results in an increase from 7MB to 300MB memory for the process in Windows.

So I would like to determine how much of this 300MB is from the Chilkat component and how much comes from my own code and/or other libraries.


Answer

You can use Microsoft Platform SDK functions to get the heap size at a specific point. If get the heap size at point A in your code, and then again at point B, you can see how much it has grown. This might help you isolate here memory growth occurs.

Some Microsoft Platform SDK functions relating to this are:

HeapLock
HeapWalk
GetProcessHeaps
GetHeapSize
HeapUnlock