From: Nicholas Nethercote Date: Tue, 4 Aug 2009 06:48:09 +0000 (+0000) Subject: Add a bit more to Massif's manual chapter. X-Git-Tag: svn/VALGRIND_3_5_0~142 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b6b2867271fab99ed8eb3e504938a129acf33b7b;p=thirdparty%2Fvalgrind.git Add a bit more to Massif's manual chapter. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10708 --- diff --git a/massif/docs/ms-manual.xml b/massif/docs/ms-manual.xml index 80c4695663..9e77eb0630 100644 --- a/massif/docs/ms-manual.xml +++ b/massif/docs/ms-manual.xml @@ -501,6 +501,7 @@ ms_print support. + Forking Programs If your program forks, the child will inherit all the profiling data that @@ -512,6 +513,66 @@ the outputs from the parent and child will be intermingled in a single output file, which will almost certainly make it unreadable by ms_print. + + +Memory Allocations Not Measured by Massif + +It is worth emphasising that Massif measures only heap memory, i.e. memory +allocated with +malloc, +calloc, +realloc, +memalign, +new, +new[], +and a few other, similar functions. (And it can optionally measure stack +memory, of course.) This means it does not directly +measure memory allocated with lower-level system calls such as +mmap, +mremap, and +brk. + + + +Heap allocation functions such as malloc are built on +top of these system calls. For example, when needed, an allocator will +typically call mmap to allocate a large chunk of +memory, and then hand over pieces of that memory chunk to the client program +in response to calls to malloc et al. Massif directly +measures only these higher-level malloc et al calls, +not the lower-level system calls. + + + +Furthermore, a client program may use these lower-level system calls +directly to allocate memory. Massif does not measure these. Nor does it +measure the size of code, data and BSS segments. Therefore, the numbers +reported by Massif may be significantly smaller than those reported by tools +such as top that measure a program's total size in +memory. + + + + + + +Acting on Massif's Information +Massif's information is generally fairly easy to act upon. The +obvious place to start looking is the peak snapshot. + +It can also be useful to look at the overall shape of the graph, to +see if memory usage climbs and falls as you expect; spikes in the graph +might be worth investigating. + +The detailed snapshots can get quite large. It is worth viewing them +in a very wide window. It's also a good idea to view them with a text +editor. That makes it easy to scroll up and down while keeping the cursor +in a particular column, which makes following the allocation chains easier. + + + + @@ -708,6 +769,18 @@ file, which will almost certainly make it unreadable by ms_print. + +Massif Client Requests + +Massif does not have a massif.h file, but it does +implement two of the core client requests: +VALGRIND_MALLOCLIKE_BLOCK and +VALGRIND_FREELIKE_BLOCK. These work in the obvious +way. + + + + ms_print Options