Free memory really low!

jgas

Active member
Hi guys!
Running free -m I noticed that lately the ram usage is REALLY high..so high that plesk is not working anymore...
I run a vps with 1.5 gb of ram!

Any idea how I can solve it? I don't really have a clue...
Thanks

Code:
>[root@musicadigitale-net ~]# free -m
>            total      used      free    shared    buffers    cached
>Mem:          1536      1433        102          0        101        819
>-/+ buffers/cache:        511      1024
>Swap:        1535        51      1484

Code:
COMMAND                  %MEM    RSS
mysqld                    4.0    62.47
spamd                    3.5    55.18
spamd                    3.5    54.14
spamd                    3.5    54.07
httpd                    3.2    50.33
httpd                    3.1    47.92
httpd                    3.0    46.85
httpd                    2.8    43.01
httpd                    2.6    40.97
httpd                    2.6    40.73
httpd                    2.6    40.59
httpd                    2.2    34.73
httpd                    2.1    32.58
iscsiuio                  1.4    22.02
httpd                    1.1    17.78
yum-updatesd              1.0    16.13
httpd                    0.5    7.80
fail2ban-server          0.3    5.14
named                    0.2    4.09
hald                      0.2    3.73

Code:
USER      PID %CPU %MEM    VSZ  RSS TTY      STAT START  TIME COMMAND
apache    2428  1.0  3.3 541300 53216 ?        S    14:03  0:14
/usr/sbin/httpd
apache    2429  1.1  3.3 541324 52276 ?        S    14:03  0:14
/usr/sbin/httpd
apache    2427  1.2  3.3 540300 52088 ?        S    14:03  0:16
/usr/sbin/httpd
apache    2431  1.2  3.2 536164 51608 ?        S    14:03  0:16
/usr/sbin/httpd
apache    2426  1.0  3.2 542316 51452 ?        S    14:03  0:14
/usr/sbin/httpd
apache    2433  1.1  3.1 537228 49496 ?        S    14:03  0:14
/usr/sbin/httpd
apache    2482  1.1  3.1 536160 49456 ?        S    14:03  0:15
/usr/sbin/httpd
apache    2430  1.1  3.0 535144 48272 ?        S    14:03  0:15
/usr/sbin/httpd
apache    2432  1.1  2.9 535316 45688 ?        S    14:03  0:15
/usr/sbin/httpd
mysql    2204  1.9  2.8 270376 44092 ?        Sl  14:03  0:26
/usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-
file=/var/run/mysqld/mysqld.pid --skip-external-locking --log-
error=/var/lib/mysql/musicadigitale-net.ggserv.co.uk.err --
socket=/var/lib/mysql/mysql.sock --port=3306
apache    2495  1.0  2.7 535180 43672 ?        S    14:03  0:14
/usr/sbin/httpd
apache    5673  1.1  1.8 530884 29864 ?        S    14:25  0:00
/usr/sbin/httpd
root      1432  0.0  1.4  28700 22552 ?        S<Lsl 14:03  0:00 iscsiuio
root      2339  0.0  1.0 520612 15788 ?        Ss  14:03  0:00
/usr/sbin/httpd
root      2721  0.0  0.9 256844 15708 ?        SN  14:04  0:00
/usr/bin/python -tt /usr/sbin/yum-updatesd
apache    2344  0.0  0.2 223352  4556 ?        S    14:03  0:00
/usr/sbin/httpd
named    2388  0.0  0.2 160324  4132 ?        Ssl  14:03  0:00
/usr/sbin/named -u named -c /etc/named.conf -u named -t /var/named/run-root
68        2683  0.0  0.2  30808  3824 ?        Ss  14:04  0:00 hald
postgres  2476  0.0  0.2 120760  3348 ?        S    14:03  0:00
/usr/bin/postmaster -p 5432 -D /var/lib/pgsql/data
root      1440  0.0  0.1  5096  3048 ?        S<Ls 14:03  0:00 iscsid
 
Are you sure? I rebooted the server and after 1hour and 30 min I have 23 mb free of ram!

2013-06-30_15h36_13.webp
 
Of the 1.4gb you're using, 1gb of that is for your cache. When you start swapping is when you have a problem and you're using 0 swap.
 
Are you sure? I rebooted the server and after 1hour and 30 min I have 23 mb free of ram!

View attachment 50258
You must be used to a Windows environment. Just because it only shows a limited amount of "free" ram doesn't mean it's all being actively used. Most of yours is in cache. Even the chart you showed relates that you are only using 30.5% of your RAM.
 
You must be used to a Windows environment. Just because it only shows a limited amount of "free" ram doesn't mean it's all being actively used. Most of yours is in cache. Even the chart you showed relates that you are only using 30.5% of your RAM.


I've never agreed with that. Mostly because when htop says I'm out of memory, it usually means I'm out of memory and I can feel & see the affects.

I've never in my life seen any Linux install which said it was using most (or all) of its ram, while also remaining smooth, fast, and stable.
 
Well, now you've seen one!
Notice the CPU load - and I am only at perhaps 1/8th of my peak traffic load (at which time the load may go to 1.5 or so, but it still runs fine).

I just checked and the average page load time seems to be less than one second diff between my busiest time of year and my slowest.

Screen Shot 2013-06-30 at 5.09.59 PM.webp
 
I've never agreed with that. Mostly because when htop says I'm out of memory, it usually means I'm out of memory and I can feel & see the affects.

I've never in my life seen any Linux install which said it was using most (or all) of its ram, while also remaining smooth, fast, and stable.
When I was running both forums on my VPS I kept about 30Mb free, and it was as responsive as when it rebooted. Of course now I don't really have to worry that much.:p
Munin's reports show that even at maximum usage I would only use about 1/3 of available memory.

example.webp
 
Well, now you've seen one!
Notice the CPU load - and I am only at perhaps 1/8th of my peak traffic load (at which time the load may go to 1.5 or so, but it still runs fine).

I just checked and the average page load time seems to be less than one second diff between my busiest time of year and my slowest.

View attachment 50275
Let me play with your system and you're CPU load and Ram will be lower, freeing up resources. The way you have it now, if you got hit hard with traffic, you'd be down sooner than I would.
 
I've never agreed with that. Mostly because when htop says I'm out of memory, it usually means I'm out of memory and I can feel & see the affects.

I've never in my life seen any Linux install which said it was using most (or all) of its ram, while also remaining smooth, fast, and stable.

Then you need to dig and find out what's causing the issue. The others in this thread are correct.

Let me play with your system and you're CPU load and Ram will be lower, freeing up resources. The way you have it now, if you got hit hard with traffic, you'd be down sooner than I would.

Yeah. Right. Keep whistling that tune.
 
Then you need to dig and find out what's causing the issue. The others in this thread are correct.
Yeah. Right. Keep whistling that tune.

Anytime you have a free VPS to spare (2GB) .... I'd be more than willing to prove this one.

This is one of those time I'd love to prove it (as opposed to those many times I care not too). If only to help kill that myth.

I've gotten into some big heated debates with a few people who would call themselves experts. Linux does run smoother, faster, and more stable when you're not using most of the resources.

So anytime you're ready.... I'm game.
 
I've gotten into some big heated debates with a few people who would call themselves experts. Linux does run smoother, faster, and more stable when you're not using most of the resources.

Take linux out of that sentence and replace it with any OS and it would still hold true. Like people have said in this thread already unless you're hitting swap/HDD you're fine. Just because RAM is "in-use" doesn't mean it isn't available. My Linux, *BSD, and Windows boxes all use nearly the same amount of RAM under load and cope fine, they just go about it differently is all.

I'd argue that either one of the *BSDs or Linux are near the top of the list when it comes to managing resources elegantly. If you're hitting swap with a ton of RAM its almost always a configuration issue.
 
I've never in my life seen any Linux install which said it was using most (or all) of its ram, while also remaining smooth, fast, and stable.
Probably because sometimes when you're out of memory, you are truly having processes exhaust all your memory.

If processes are eating all your memory, it's going to cause performance problems, but memory allocated to disk caching is always free for processes to allocate. It's not some urban myth that you can agree/disagree with, that's how Linux manages its memory. With Linux being open source, this isn't some kind of guessing game.

http://www.linuxatemyram.com/play.html

As for swap, I don't think servers should have any at all, but that's a different discussion.
 
Swap? A well configured system will not even touch it.

So also agreed.

That's not always true, it's valuable for holding leaked pages and other useless things that shouldnt be in ram (e.g. idle tmpfs files, unused threads/caches/buffers/whatever)

On an average day my server has 12 out of 16GB RAM in use (4GB os cache) and about 8-10GB in swap. About 80% of the stuff in swap is leaked from SRCDS, typical Valve :P
 
Let me play with your system and you're CPU load and Ram will be lower, freeing up resources. The way you have it now, if you got hit hard with traffic, you'd be down sooner than I would.

I've gotten hit with over 100,000 page loads a day - which is pretty good for a 2+ year old server with nothing fancy - and the system never burped.

Good enough is more than good enough. Most of the delays are on the other end (the browser, etc.).

Unless I had a DOS attack, the traffic is simply got going to scale up hard....
 
I've never agreed with that. Mostly because when htop says I'm out of memory, it usually means I'm out of memory and I can feel & see the affects.

I've never in my life seen any Linux install which said it was using most (or all) of its ram, while also remaining smooth, fast, and stable.
Strange, are you reading free command properly ?

On Centos, when i compare free and htop commands they both agree with each other as to how much memory is actually in use. Just that htop doesn't report your buffer/cache usage. So yes, when htop says you're memory usage is 100% then free command would say the same.

i.e. when free reports 79MB used
Code:
free -m
            total      used      free    shared    buffers    cached
Mem:          499        377        121          0        142        155
-/+ buffers/cache:        79        419
Swap:            0          0          0

htop reports 80 out of 499MB used. So they both same the same thing, just htop doesn't report the cache/buffer usage ;)

check your /proc/meminfo for full details

Code:
cat /proc/meminfo
MemTotal:        511040 kB
MemFree:          123856 kB
Buffers:          146340 kB
Cached:          158880 kB
SwapCached:            0 kB
Active:          171672 kB
Inactive:        180468 kB
Active(anon):      66600 kB
Inactive(anon):    11772 kB
Active(file):    105072 kB
Inactive(file):  168696 kB
Unevictable:          0 kB
Mlocked:              0 kB
HighTotal:            0 kB
HighFree:              0 kB
LowTotal:        511040 kB
LowFree:          123856 kB
SwapTotal:            0 kB
SwapFree:              0 kB
Dirty:                4 kB
Writeback:            0 kB
AnonPages:        46928 kB
Mapped:            13416 kB
Shmem:            31456 kB
Slab:              28640 kB
SReclaimable:      23200 kB
SUnreclaim:        5440 kB
KernelStack:        696 kB
PageTables:        1508 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:      255520 kB
Committed_AS:    425256 kB
VmallocTotal:    505856 kB
VmallocUsed:        3912 kB
VmallocChunk:    475788 kB
HugePages_Total:      0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:      2048 kB
DirectMap4k:        8184 kB
DirectMap2M:      516096 kB

Above memory usage is from CentOS 6.4 32bit, 512MB VPS running Centmin Mod Nginx 1.4.1, PHP 5.4.16 and MariaDB 5.5.31 MySQL with memcached server and APC Cache with Wordpress, Xenforo (3k posts) and vBulletin 4.2 forum on same server.
 
Last edited:
Look.... If you have 2 GB of ram and you're using or holding onto only 100 MB (for example).... You're going to be better off than the guy who is using or holding onto 1,900 MB (1.9 GB) cached or swapped or otherwise.

Doesn't matter if its Windows, Apple, Linux, or FreeBDS. The less you're using the better and nothing anyone here post will convince me otherwise.

I've proven this to a whole mass of individuals who all got their panties in a bunch on CentOS and on Ubuntu.

Unless I had a DOS attack, the traffic is simply got going to scale up hard....
Especially on a DDOS attack. You're setup will kill over way before mine does, because its going to take less to push you over.


Anytime someone has a free VPS.... Let me know.... I'll be more than happy to dance on this myth.
 
Back
Top Bottom