Re: Shared memory - using ps(1)
On Tue, May 02, 2006 at 01:42:28AM -0400, Roberto C. Sanchez wrote:
> I get your point. Hopefully you get mine :-)
I hope I get both points. ;)
My 20 processes of statically linked MySQL may share memory between
themselves (because they were forked from a parent??) but if MySQL
was linked with libc, that won't be shared with other dynamically
linked programs that use libc. So libc is using double the memory
in this case.
I was looking at /proc/<pid>/smaps for Apache2, postgresql 8.1, and
(the famous statically linked MySQL). I just wrote a little perl
script to tally up the various counts -- which is probably
meaningless (since you can't add up a bunch of processes' shared
memory because it's, well shared).
The program displays the /proc/<pid>/smaps info for all processes
padded and then shows totals. I've clipped all output except for two
pids and the total.
$ perl smaps.pl `pidof apache2` (5 pids)
So, if all those processes are in physical RAM at the same time can I
assume that they use at least 88484K (plus whatever is shared in all)?
Now looking at MySQL:
$ perl smaps.pl `pidof mysqld--kernis` (21 pids)
Here's where I'm curious. 680MB of private memory. It's likely that
not all of that will be in RAM at the same time. (For one thing, the
machine does not have that much traffic). But, in general, as
connections are made to MySQL don't they basially round-robin. In
other words, say 10 of the 20 processes have much of their private
memory swapped out. It's not like only the 10 with all their memory
still in physical RAM will somehow handle all connections to MySQL.
So my guess is:
Even with low MySQL traffic having more processed than needed
causes swapping to happen since connections to MySQL will cycle
through all MySQL processes and potentially bring them in and out of
Of course, it's not that simple. ;)