Releasing ram in linux

Hyperblaze

Lifer
May 31, 2001
10,027
1
81
On one of the linux servers at work, After a while there appears to be quite a bit of memory being used. After killing all the applications, is there a way to release any inused ram?

 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
If the applications that were using the ram were killed then the ram is free...
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
Do you think you have memory leaks or something?

If so then restarting the application should get rid of them temporarially.

Ofter ram will get 'used' as cache for file system. This helps speed things up as disks are the slowest part of the computer and avoiding disk access when ever possible usually causes a nice performance increase.

But in Linux telling what memory is doing can be confusing.
 

Hyperblaze

Lifer
May 31, 2001
10,027
1
81
Originally posted by: drag
Do you think you have memory leaks or something?

If so then restarting the application should get rid of them temporarially.

Ofter ram will get 'used' as cache for file system. This helps speed things up as disks are the slowest part of the computer and avoiding disk access when ever possible usually causes a nice performance increase.

But in Linux telling what memory is doing can be confusing.

The only think I can really think of is firefox?

I abuse it on the system quite a bit (I use the GUI on the server )
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
Firefox does it's own thing that is seperate from the operating system in order to make browsing faster. It keeps a cache on disk and keeps a cache in RAM. Also it uses A LOT of X server memory (to display images and such). Then on top of that everything is dynamicly generated so that not much is shared with other applications.

So it can be best described as a 'memory hog'. It will actually adjust itself to consume more memory the more memory you have aviable. If you have 256 megs of RAM it will use less ram then if you have 2gigs. (or at least it seems that way)

If it's not having a negative impact on performance (like your system doesn't start using swap partition for memory) then your fine.

Probably the best solution you can have is to get a proper Linux workstation to administrate your servers from and learn to use X over ssh (or NX) to get to the various GUI tools you may need.

 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
With all of the browser issues out there right now, DON'T use a browser on your servers.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
If the 'cached' column in 'free' output is really high that's where your memory is and it's essentially free, that's the filesystem cache and it'll be reused as necessary. If you want to flush the filesystem cache, and you probably don't want to, you can 'echo 3 > /proc/sys/vm/drop_caches' if your kernel is new enough. But as I said, you probably don't want to do that since it'll just cause all of the stuff that really is in use to be paged back in so your disks will go crazy if the box is actually doing something.

And I second n0c's suggestion to stop using FF on the server, that's a really bad idea.
 

nweaver

Diamond Member
Jan 21, 2001
6,813
1
0
third to say don't use X/FF on the server...

if you are worried about memory, why are you running X anyway? I run X on my workstation only. I don't normally even forward X, as there aren't that many GUI tools I use. I normally don't have X installed.

As far as releasing memory, realize the Linux manages memory (imho) leaps and bounds better then windows. It'll actually USE your memory to it's fullest.
 

silverpig

Lifer
Jul 29, 2001
27,703
11
81
It's kind of funny how there's a lot of threads where people buy 2 gigs of ram and only want their OS to ever use 512 MB
 

bersl2

Golden Member
Aug 2, 2004
1,617
0
0
From where are you getting the amount of free/used memory? Does it take into account the buffers and caches that are expendable if an application needs the space?
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
Originally posted by: Nothinman
If the 'cached' column in 'free' output is really high that's where your memory is and it's essentially free, that's the filesystem cache and it'll be reused as necessary. If you want to flush the filesystem cache, and you probably don't want to, you can 'echo 3 > /proc/sys/vm/drop_caches' if your kernel is new enough. But as I said, you probably don't want to do that since it'll just cause all of the stuff that really is in use to be paged back in so your disks will go crazy if the box is actually doing something.


There was a nice article on doing stuff like that I just remembered. Pretty new.
http://aplawrence.com/Linux/buffer_cache.html

It's kind of funny how there's a lot of threads where people buy 2 gigs of ram and only want their OS to ever use 512 MB

Well it makes sense. The purpose of a OS is to run the applications. So this means that the OS needs to be as light weight as possible (while retaining the sophistication needed for stability and performance) to make the most efficient use of the computer to drive the application.

Doesn't help also that each application and each place you look at in Linux will give you a different statistic on 'memory usage'.
 

silverpig

Lifer
Jul 29, 2001
27,703
11
81
Originally posted by: drag
Originally posted by: Nothinman
If the 'cached' column in 'free' output is really high that's where your memory is and it's essentially free, that's the filesystem cache and it'll be reused as necessary. If you want to flush the filesystem cache, and you probably don't want to, you can 'echo 3 > /proc/sys/vm/drop_caches' if your kernel is new enough. But as I said, you probably don't want to do that since it'll just cause all of the stuff that really is in use to be paged back in so your disks will go crazy if the box is actually doing something.


There was a nice article on doing stuff like that I just remembered. Pretty new.
http://aplawrence.com/Linux/buffer_cache.html

It's kind of funny how there's a lot of threads where people buy 2 gigs of ram and only want their OS to ever use 512 MB

Well it makes sense. The purpose of a OS is to run the applications. So this means that the OS needs to be as light weight as possible (while retaining the sophistication needed for stability and performance) to make the most efficient use of the computer to drive the application.

Doesn't help also that each application and each place you look at in Linux will give you a different statistic on 'memory usage'.

I guess I should have said computer then. People run firefox, thunderbird, IM etc and try to keep releasing ram so they'll "run faster".
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
There was a nice article on doing stuff like that I just remembered. Pretty new.
http://aplawrence.com/Linux/buffer_cache.html

Although sadly the guy doesn't seem to have any clue as to how the drop_caches stuff is implemented, he even lists his failed attempts to corrupt a file and can't figure out why it didn't work. It only takes a minute to open up fs/drop_caches.c see that the drop_pagecache function eventually calls invalidate_mapping_pages which has a huge comment at the top that says "It will not invalidate pages which are dirty, locked, under writeback or mapped into pagetables." so there's no need to call sync before touching it.

Ah even better is that the site that he links to linux.inet.hr as a reference for the drop_caches information specifically says that it'll only drop clean pages.

And he keeps referring to the caching as the buffer cache which is seperate from the page cache in Linux and is rarely used these days.
 

Hyperblaze

Lifer
May 31, 2001
10,027
1
81
thanks for the suggestion guys. I know it's my own damn fault for using firefox.

Guess I'll have to build another linux box just to act like a server.
 

willtriv

Member
Oct 21, 2005
149
0
0
no meng, ram in linux is supposed to be full. Just because your little status monitor or /sbin/free or w/e it is tells you its all used up doesn't mean there isn't room, it moves stuff out on the fly too. If your not using 100% of your ram, you should have saved your money, or you should have rebuilt your kernel with iommu or something. After 123 days of uptime my server has 13k free ram. Thats good, it means CS and apache are totally crammed in there and all the popular files they run thru just sit in there unless they've changed. It's good to have your ram full, X 7.X has some weird leaks and restarting that can help though. Otherwise your system is running prime
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
Originally posted by: Nothinman
There was a nice article on doing stuff like that I just remembered. Pretty new.
http://aplawrence.com/Linux/buffer_cache.html

Although sadly the guy doesn't seem to have any clue as to how the drop_caches stuff is implemented, he even lists his failed attempts to corrupt a file and can't figure out why it didn't work. It only takes a minute to open up fs/drop_caches.c see that the drop_pagecache function eventually calls invalidate_mapping_pages which has a huge comment at the top that says "It will not invalidate pages which are dirty, locked, under writeback or mapped into pagetables." so there's no need to call sync before touching it.

Ah even better is that the site that he links to linux.inet.hr as a reference for the drop_caches information specifically says that it'll only drop clean pages.

And he keeps referring to the caching as the buffer cache which is seperate from the page cache in Linux and is rarely used these days.

Ya. He is mostly a old SCO guy who found OS X religion so he is used to the ability just to bork your system up royally from doing stuff like that. But normally he is pretty sharp and he did update the article with his failed tests to show that there was something wrong with his assumptions.

If you make a note of were he got it wrong in the comments of the article he will probably be quite greatfull for the correction.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |