• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Releasing ram in linux

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?

 
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.
 
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 😛 )
 
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. 😉

 
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.
 
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.
 
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 🙂
 
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?
 
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'.
 
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".
 
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.
 
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.
 
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 🙂
 
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.
 
Back
Top