[plug] Does this appear to be a memory leak?

Craig Ringer craig at postnewspapers.com.au
Sun Oct 24 18:04:06 WST 2004


On Sun, 2004-10-24 at 10:00, Tim White wrote:

> After looking at the amount of mail handled by Thunderbird I am think it 
> may be loading the indexes into memory or something. Ether that or lots 
> of shared libraries. Hopefully someone else knows.

If I recall correctly, the VSZ measures the amount of virtual memory the
program has mapped. This includes (a) mmap()ped files, and (b) shared
libraries, among other things. Neither the ps nor top manpages bother to
describe this field, so I can't be sure.

Thunderbird may well be mmap()ing your mail files to access them. As for
gxmms, being a GTK or GNOME app it's likely to load a _lot_ of
libraries. Both of these will, if I understand things correctly,
increase VSZ without increasing the "real" memory use of your program.

A good example of this is how XFree86 can sometimes have a VSZ that is
larger than your system's physical memory + used swap (monster video
card in an old system, usually). I seem to recall this being possible
due to XFree86 mmap()ing the video card memory or something like that.
On my system, for example, X is shown as using 153M VSZ, but my system
is currently only using 200mb of physical memory and 50MB of swap. Given
everything else that's running, it is _very_ unlikely that X is actually
consuming that amount of memory.

The RSS of a process shows the actual amount of physical memory in use
by a process, and is generally an accurate measure of the "real" size of
the process when your system is not using much or any swap. If you're
working on a system that's swapping and trying to determine why, it
won't be as useful, though the 'SWAP' field supported by top may be.

I strongly recommend you read the 'FIELD DESCRIPTIONS' section of the
top(1) man page. It looks like you might want to run `top' and explore
its help, too - in particular, controlling what fields are shown and
what the sort order is.

Unfortunately, I don't know if either ps or top provide a way to find
out "how much memory is this process using, counting its binary but not
shared libraries, and not counting mmapped files." For that matter, even
this measure wouldn't be useful, as some applications load shared
libraries only they use (OO.o, Evolution, and the mozilla apps, for
example).

If you want to find out the real amount of memory used by a process, the
only reliable way I have found out to do so is to run `free', exit the
process, and run `free' again. If nothing else has changed, the change
in used memory is generally a useful indicator of how much it was
actually using.

Hope this is helpful, and not _too_ riddled with errors ;-)

> >> 1402 root       5 -10 68684  12m  49m S  4.0  5.2 192:30.04  54m XFree86
> >> 1809 tim       16   0 40380 9260  19m S  0.0  3.6   1:08.43  30m nautilus
> >>-- after kill
> >> 5652 tim       15   0 19036 8436  16m S  0.0  3.3   0:00.49  10m gxmms

--
Craig Ringer




More information about the plug mailing list