Page 1 of 1

Weird memory usage problem

PostPosted: Nov 23rd, '13, 19:31
by Palewolf
Ever since i installed Mageia 3 at work i've noticed abnormally high memory usage on that computer (about 1.3 gigs idle). This is a development computer with httpd + php + mysql + smb, so little extra memory is expected.
However, what puzzles me is that the memory used is not accounted for, ie, you can manually add the memory used by all the processes and it won't be equal to what's reported as used.
Now, i know about the caching used in linux, but that's not the case here: something chews up active resources, and never lets go of them.
What's even wierder is that if i request the kernel to free caches, it releases active memory!

For example:
Code: Select all
# free -m
             total       used       free     shared    buffers     cached
Mem:          3004       2932         72          0        773        863
-/+ buffers/cache:       1295       1709
Swap:         3991          0       3991
# sync; echo 3 > /proc/sys/vm/drop_caches
# free -m
             total       used       free     shared    buffers     cached
Mem:          3004        878       2126          0          3        221
-/+ buffers/cache:        653       2351
Swap:         3991          0       3991


As you can see, requesting drop_caches frees a whopping 600 MB of user memory! That, on a 3 GB computer, is a lot.

I haven't been able to pinpoint what's using up the memory, but i can say for sure it rises a lot when running disk-intensive programs like msec. Any ideas?

Re: Weird memory usage problem

PostPosted: Nov 23rd, '13, 20:45
by jiml8
I would say don't worry about it. The system uses free memory for cache and returns it as required. Here's mine:
Code: Select all
root@localhost:src> free
             total       used       free     shared    buffers     cached
Mem:      32866168   31496316    1369852          0    2921816   21075240
-/+ buffers/cache:    7499260   25366908
Swap:      2144124          0    2144124
root@localhost:src> flush
root@localhost:src> free
             total       used       free     shared    buffers     cached
Mem:      32866168   10298368   22567800          0       2480    5224380
-/+ buffers/cache:    5071508   27794660
Swap:      2144124          0    2144124


the "flush" command is a bash macro that I have in .bashrc which is the same as what you wrote out in your first post.

The memory manager in linux is very complicated, and every tool reports memory usage differently, depending on how it treats shared resources. For myself, I have never found it necessary to become a guru in this area. I don't worry about it and just pay attention to how much memory is free after a flush. It only becomes an issue if the free memory is small and swap begins to be used.

However, with 32 GB of RAM in this system, I seldom have less than 8 GB free after a flush, and as you can see from my listing I have 22 GB free at the present time.

Re: Weird memory usage problem

PostPosted: Nov 24th, '13, 03:17
by Ken-Bergen
Palewolf wrote:As you can see, requesting drop_caches frees a whopping 600 MB of user memory! That, on a 3 GB computer, is a lot.

I haven't been able to pinpoint what's using up the memory, but i can say for sure it rises a lot when running disk-intensive programs like msec. Any ideas?
It would seem that your memory is being handled correctly.

When you or the system start any program it loads into memory.
When the program closes it remains in memory as cached which means that next time that program is started it's already in memory so starts faster.
If you or the system start another program that needs more memory than is reported as free then one or more programs that are cached get dumped to make room for it.
The same applies to buffers.

The only time to be concerned is if you start using a lot of swap and from your output you haven't touched swap yet.