[OT] finding memory hungry bits of my code

Mark Morgan makk384 at gmail.com
Thu Apr 9 14:42:02 BST 2009

On Thu, Apr 9, 2009 at 2:08 PM, Edmund von der Burg
<evdb at ecclestoad.co.uk> wrote:
> Perhaps you're right - but our cruising altitude would seem to be very
> high: our biggest processes according to top:

I'll take a guess that you're using Redhat, or some derivative
thereof.  The perl included with that includes a lot of things as
shared modules (the big one, if memory serves me correctly is
locale-related).  `ldd perl` will show if this is the case.  This
amount gets included in the memory info that linux top/ps returns,
which has a tendency to really bloat the figures.

> Do these numbers look reasonable to others? The SHR value seems crazy
> low, but that might be me reading it all wrong.

Yep, that's what we ran into, when trying to do an analysis of memory
usage at a previous company.  You can look at /proc/<pid>/mem to get
at the memory map, and see what shared libs are being used, size of
stack/heap/etc (though in spending a few minutes now, I couldn't find
anything that tells what the other values in this file represent

> Almost everything gets preloaded in our startup.pl script so it should
> get shared.

A simple (though very limited) determination of memory usage under
apache would be to start up with x processes, check free memory/swap,
kill it, and start with x+1 processes, and see the difference.  Will
give some indication as to the baseline memory usage for each apache
instance.  Doing similar with a couple of requests put through each
may show if some modules aren't being preloaded as you thought.


More information about the london.pm mailing list