I got VPS and have ubuntu on top of it. I have installed apache in worker role (not prefork ) also installed ruby EE 1.8.7 & mysql 5.x

Now when I check for memory I see 18.6 % (of 924 MB ) is used by the rack ( must be rails app that I am running)

and When I do free -m I get the following results :

             total       used       free     shared    buffers     cached
Mem:           924        602        322          0          0          0
-/+ buffers/cache:        602        322
Swap:            0          0          0

where is my memory used up ? free -m shows all the memory used is my the cache and nothing else how is that possible ? I don't have any users for the site as of now.

AUX doesn't show anything interesting except 18.6% by rack and 2.6% by mysql .

As soon as I shut down my apache instance the memory comes down to 150 mb.

List of apache modules loaded:

 core_module (static)
 log_config_module (static)
 logio_module (static)
 mpm_worker_module (static)
 http_module (static)
 so_module (static)
 alias_module (shared)
 auth_basic_module (shared)
 authn_file_module (shared)
 authz_default_module (shared)
 authz_groupfile_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 cgid_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 mime_module (shared)
 negotiation_module (shared)
 reqtimeout_module (shared)
 rewrite_module (shared)
 setenvif_module (shared)
 status_module (shared)
 passenger_module (shared)

This is the result of cat /proc/meminfo

MemTotal:       946344 kB
MemFree:        336624 kB
Buffers:             0 kB
Cached:              0 kB
SwapCached:          0 kB
Active:              0 kB
Inactive:            0 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:       946344 kB
LowFree:        336624 kB
SwapTotal:           0 kB
SwapFree:            0 kB
Dirty:               0 kB
Writeback:           0 kB
AnonPages:           0 kB
Mapped:              0 kB
Slab:                0 kB
PageTables:          0 kB
NFS_Unstable:        0 kB
Bounce:              0 kB
CommitLimit:         0 kB
Committed_AS:        0 kB
VmallocTotal:        0 kB
VmallocUsed:         0 kB
VmallocChunk:        0 kB
HugePages_Total:     0
HugePages_Free:      0
HugePages_Rsvd:      0
Hugepagesize:     2048 kB
  • Have you tried "top" or "htop"?
    – Michael K
    Sep 7, 2011 at 10:41
  • yes I am getting the 18.6% etc results using top Sep 7, 2011 at 10:50
  • Is the rest of the memory really occupied so you cannot use it? The memory display may be tricked by cached data that gets overwritten if you try to access the space. Also, have you tried using your mem display as root? the root user may have processes running that won't be shown to other users.
    – Michael K
    Sep 7, 2011 at 11:30
  • I tried clearing all my cache and also got all the results as root user. Sep 7, 2011 at 12:54
  • also shutting down apache releases 450 mb ... where the apache is running only with one rails app and 1 user for the app. Sep 7, 2011 at 12:56

2 Answers 2


There are a couple reasons for the behavior you are seeing. First:

  • ps aux's % is based on resident:

    %mem       %MEM    ratio of the process's resident set size  to the physical memory on the machine, expressed as a percentage. (alias pmem).
  • free's report includes things other than Active memory (the resident/%MEM from ps) when displaying values

The gist of this is that when you look at free, you are seeing VSZ and other allocations being added up when displaying the total. When you look at the % in ps, you are only seeing a piece of the puzzle.

To verify this you can look at two things, first run:

$ ps aux
www      18442  0.0  0.0 519156 65460 ?        Sl   Sep08   1:47 httpd

You should see that the VSZ will be considerably larger than the RSS and if you do the calculations would probably yield a much bigger % if included.

Secondly, you can check the real amount of memory in use by looking at /proc/meminfo directly:

# cat /proc/meminfo 
MemTotal:       99197880 kB
MemFree:        72697684 kB
Buffers:        13813488 kB
Cached:          4841820 kB
SwapCached:          196 kB
Active:          4662952 kB

You'll notice that the 'used' column from free is more than just Active(roughly RSS from ps).

The actual explanation of why this is is actually covered in a collection of several books which are a really great read if you are trying to fall asleep, but you can get some basic understanding from a couple articles:

Meminfo: http://www.redhat.com/advice/tips/meminfo.html

ps/virtual and VSZ explained: http://virtualthreads.blogspot.com/2006/02/understanding-memory-usage-on-linux.html

  • you gave me a broader sense for memory in linux .. +1 for that. But the problem is I am still stuck with "where is my memory gone" .. RSS value sums up to somewhere 250mb and the vsz ah it comes to 1200 mb . How do I figure what is killing my memory ? Sep 13, 2011 at 4:08
  • also added /proc/meminfo for reference. Sep 13, 2011 at 4:09
  • and why does shutting apache releases 450 mb ? Sep 13, 2011 at 4:44
  • Remove all the module loads and start apache, then add them back one by one to see which one is consuming all the memory.
    – polynomial
    Sep 13, 2011 at 5:55

If shutting down Apache releases 450mb (approx half of your memory), then start looking at Apache. Look that the modules that it loads on startup, any related environmentals, and any memory consumed answering requests. You might might a module that is a bit memory heavy or leak in your app. Also look at number of workers at startup and the worker pool size.

  • its 3/4th of my memory ... I added the list of modules.. doesn't seem the list is high. Even when there are no requests the memory is at such a state. Sep 8, 2011 at 4:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.