Hi.
Are you sure this is *actual memory usage* and not just VM size?
Passenger creates multiple threads. Because of the nature of threads,
memory usage for multi-threaded applications are usually misreported.
For example, a demo application that creates 100 threads (each thread
doing nothing) appears to be using 800 MB memory, according to ps's
"VSZ" column. But actual memory usage is only 532 KB - a significant
difference!
People usually read the "VM size" or "VSZ" column from process reporting
tools such as "ps" or "top", and it's likely that you've read that as
well. However, this column does not report memory usage accurately.
Unfortunately, "ps" and "top" do not provide facilities to report the
actual memory usage. GNOME System Monitor provides the most accurate
memory usage report, through the "Writable memory" column.
You probably don't have GNOME System Monitor installed. But you can also
find out the actual memory usage of a single process by measuring its
"private dirty RSS" with the following command (this only works on Linux):
grep Private_Dirty /proc/XXXX/smaps | awk '{ print $2 }' | xargs ruby -e
'puts ARGV.inject { |i, j| i.to_i + j.to_i }'
where 'XXXX' is the PID of a process. This reports memory usage in KB.
The best way for you to find out how much memory Apache (i.e. all Apache
processes combined) _really_ uses, is through 'free -m'. I suspect that
if you:
1. start Apache
2. measure the memory usage with 'free -m'
3. stop Apache
4. measure with 'free -m' again, and calculate the difference,
that you will find that the actual memory usage is significantly lower
than what is reported by 'ps'.
Many people have been fooled by this phenomenon, and indeed, I don't
understand why the authors of 'ps' and 'top' haven't updated their tools
to correctly report actual memory usage.
Wikipedia also elaborates this phenomena at
http://en.wikipedia.org/wiki/Virtual_memory.
--
Phusion | The Computer Science Company
Web: http://www.phusion.nl/
E-mail: in...@phusion.nl
Chamber of commerce no: 08173483 (The Netherlands)
Hi Clarke.
There may be all kinds of reasons why this is so. But I'll need more
information about your environment.
- How many Apache worker processes were running at the time?
- What are the PID, VM size and private dirty RSS for each Apache worker
process?
- What is the PID, VM size and private dirty RSS of the Apache control
process?
- What are the VM size and private dirty RSS of the spawned Rails processes?
- What are the VM size and private dirty RSS of the "Passenger
SpawnManager", "Passenger FrameworkSpawner" and "Passenger
ApplicationSpawner" processes?
I know this is quite a lot of information that one has to gather. But
it'll really help if you could provide them. :)
Could you post the exact error message?
Hi maerzbow.
No offense taken/intended. :) I just want people to be properly informed
about the truth.
FYI, I've written a memory statistics gathering tool. It's in the latest
development version (i.e. the git repository), as
'misc/memory_stats.rb'. If you have the time, please run this tool to
gather memory statistics. Note that this tool only works on Linux.
With kind regards,
Hongli Lai
--
Phusion | The Computer Science Company
Web: http://www.phusion.nl/
E-mail: in...@phusion.nl
Please run this tool as root, otherwise it can't determine the private
dirty RSS.
> can I ask what those 6 processes are?
Those are the Apache worker processes. They're explained in
http://httpd.apache.org/docs/2.2/mod/prefork.html
They're part of Apache, not Passenger.
--
Phusion | The Computer Science Company
Web: http://www.phusion.nl/
E-mail: in...@phusion.nl
thanks for creating mod_rails!
--
chunky bacon!