Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Those numbers cannot be compared really. Even pages belonging to a (shared) memory mapped file (e.g. a library) will count as resident pages for the task. But they will be ignored by the Leak Tester.</p> <p>The important thing to note is that there is a conceptual difference between memory available to the process (in whatever way: readonly, read/write, executable or not) and memory allocated by you, within your program. Not all available memory is connected to an actual allocation you did (e.g. a shared library) and not all memory you allocate is necessarily resident in memory (e.g. a big malloc will not reserve physical memory for you right away, but only as soon as it is used).</p> <p>You can test the impact of this by mapping an anonymous region of memory (or a file) using:</p> <pre><code>#include &lt;sys/mman.h&gt; // allocate anonymous region of memory (1 mb) char *p = mmap(NULL,1024*1024,PROT_WRITE|PROT_READ,MAP_PRIVATE|MAP_ANON,0,0); // actually access the memory, or it will not be resident int sum=0; for(int i=0;i&lt;1024*1024;i++ ) sum += p[i]; </code></pre> <p>You can easily change this to <code>mmap</code> a file, by passing an fd to <code>mmap</code> and changing <code>MAP_ANON</code> to <code>MAP_FILE</code>.</p> <p>Also, presumably the leak tester looks from the <code>malloc</code> (library) call onward until a corresponding <code>free</code>, while the actual memory reservation is done just one level lower, e.g. using a <code>mmap</code> (system) call just like the one above.</p>
 

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