Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can use existing memory debugging tools for this, I found Memory Validator <a href="http://www.vmvalidator.com/cpp/memory/index.html" rel="nofollow noreferrer" title="Memory Validator">1</a> quite useful, it is able to track both API level (heap, new...) and OS level (Virtual Memory) allocations and show virtual memory maps.</p> <p>The other option which I also found very usefull is to be able to dump a map of the whole virtual space based on VirtualQuery function. My code for this looks like this:</p> <pre><code>void PrintVMMap() { size_t start = 0; // TODO: make portable - not compatible with /3GB, 64b OS or 64b app size_t end = 1U&lt;&lt;31; // map 32b user space only - kernel space not accessible SYSTEM_INFO si; GetSystemInfo(&amp;si); size_t pageSize = si.dwPageSize; size_t longestFreeApp = 0; int index=0; for (size_t addr = start; addr&lt;end; ) { MEMORY_BASIC_INFORMATION buffer; SIZE_T retSize = VirtualQuery((void *)addr,&amp;buffer,sizeof(buffer)); if (retSize==sizeof(buffer) &amp;&amp; buffer.RegionSize&gt;0) { // dump information about this region printf(.... some buffer information here ....); // track longest feee region - usefull fragmentation indicator if (buffer.State&amp;MEM_FREE) { if (buffer.RegionSize&gt;longestFreeApp) longestFreeApp = buffer.RegionSize; } addr += buffer.RegionSize; index+= buffer.RegionSize/pageSize; } else { // always proceed addr += pageSize; index++; } } printf("Longest free VM region: %d",longestFreeApp); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload