How to remove cached memory?

thomaskv
Posts: 10
Member Since:
2007-01-19

Hi all

I am fairly new to trixbox, and have 2 machines running it now. Both are just test-machines. One fairly low end (256MB memory) and one a bit better (512MB memory).

I have noticed on both that trixbox, I am not sure exectly which program or job that does this, caches up a lot of stuff in the memory. It seems to just cache more and more, until used memory is at 98%, 40% of which is cached. This is on the low-end machine. On the other one, the used memory is a bit lower, but the cached part still takes up around 40%, and it seems to be growing. They have both been up for about 4-5 days.

I have checked around, and many people say that this is how it should be. However, I would still like to know how I can release this cached memory, if possible, just so that I can test how this affects performance.

Also, if anyone knows which program it is that does this caching (is it asterisk, linux or any of the other jobs?), I would really like to know.

Thanks in advance

--Thomas



Clint.Davis
Posts: 170
Member Since:
2006-07-02
Re: How to remove cached memory?

You prob want to watch # top

and see whats using it.

First on a low end system, i would stop apache (after you have configured the system)

And also stop the script for genorating the flash document for FOP.

Then also use # setup

And disable services you dont need eg. pcmcia etc

Oh: and edit the zaptel script and only have in there the card your using, so it wont modprobe all of the other drivers as well.



thomaskv
Posts: 10
Member Since:
2007-01-19
Re: How to remove cached memory?

Thank you for a speedy answer =)

But I am using the web-interface alot, to change and monitor the PBX, so I cant really turn off Apache, can I? And the same with the FOP, if the flash panel is in use, you kinda need the script I assume?

What I was thinking of, was some way to flush (or dump or whatever) that which has been cached, so I can free up memory, say, every night or so? I can't really tell which program it is that is doing all this caching, is it asterisk, apache, linux or perhaps all of them...?



dickson
Posts: 1831
Member Since:
2006-06-02
Re: How to remove cached memory?

Why are you trying to fix something that isn't broken?



thomaskv
Posts: 10
Member Since:
2007-01-19
Re: How to remove cached memory?

It is just something that I want to be able to experiment with, to see if it might have a positive impact on performance. It probably wont, but I want to learn more and experiment with this, so I would appreciate all the help I can get.

I have tried to restart Asterisk, Apache and MySQL now, and nothing frees up any memory. The 256MB machine is now at 99% used memory constantly. Any ideas as to how I can free up some? 37% of it is cache, this has to be dumpable in some way...

--Thomas

Edit: I tried some more, and restarting Apache does free up some memory. However, this is just ordinary physical memory, the cached part stays the same. Apache also quickly consumes up the memory it released on restart...

What is this cached memory exactly? Which program is it that Caches it, and how can I control it?



LBSources
Posts: 89
Member Since:
2006-10-12
Re: How to remove cached memory?

I think the OP has a valid question here. I'm experiencing a similar issue and i'm not sure upgrading is the best solution.

No one is trying to fix anything .. just trying to keep resources at a minimum. If they cant be kept at a minimum, it would be nice to understand the reason why they cant be.



thomaskv
Posts: 10
Member Since:
2007-01-19
Re: How to remove cached memory?

Yeah, thanks. Thats exactly how i feel.

I have been looking around alot, but i cant seem to find anything on this. The problem here is that I am planning on running several applications on my PBX, not just asterisk. I figured that it might work fine for trixbox to run on 99% used memory all the time, but when installing other programs, there might be some problems. There probably wont be any, but I want to be prepared, just in case.



eselliso
Posts: 3
Member Since:
2006-10-15
Cache Memory

I also have tried to find a way to dump the Cache Memory but was never successful. My heart burn is that the memory bar turns red once it exceeds 90%. To me, that is an alarm. Once a system is brought up on a re-boot all the memory utilizations are low but they gradually increase until the total gets above 90%. Something I have done as an experiment is to activate SAMBA then transfer a large file, 300MB, into the Asterisk Server then immediately delete the file off the Server. The Cache drops immediately as if it was Caching some of the file transfer then removes it when the file is deleted.



KodaK
Posts: 1885
Member Since:
2006-06-14
I'm not sure what you're

I'm not sure what you're referring to when you say "the memory bar turns red" but I can assure you that Linux uses cache efficiently.

Look at it this way: if you're not doing anything with your RAM, why shouldn't the system use it to cache? The cache gets low priority, and gets overwritten with any "real" data without any extra effort (the caching is part of the kernel -- unless you compile it out (and I don't even know if that's possible) it's not going to stop.)

Now that I've said that, what exactly do you mean when you talk about "the red bar?" If you're having issues with RAM capacity and you have 512MB or more then there certainly may be something wrong with your setup.

To re-iterate, it's normal and desired for your RAM to be 90%+ used in Linux. The time to start worrying is if there is excessive swap, or (IMO) any swap on a telecom system. Add more RAM and remove unneeded services. :)

--

WARNING: I no longer actively participate in these forums. My thoughts on trixbox in a nutshell: http://www.youtube.com/watch?v=q4xBMkWu1pE Use AsteriskNOW instead.



KodaK
Posts: 1885
Member Since:
2006-06-14
I keep forgetting that some

I keep forgetting that some of you guys are Linux newbies.

So I don't re-invent the wheel, here is a very good explanation of the Linux memory management system:

http://forums.gentoo.org/viewtopic.php?t=175419

--

WARNING: I no longer actively participate in these forums. My thoughts on trixbox in a nutshell: http://www.youtube.com/watch?v=q4xBMkWu1pE Use AsteriskNOW instead.



eselliso
Posts: 3
Member Since:
2006-10-15
Memory Cache

This link has a capture from the Admin mode of my Trixbox. It clearly shows the Memory Bar in the Red. This is what alarms me. If everything is OK it should be Green all the time. http://bellsouthpwp.net/e/s/eselliso/trixbox.jpg



thomaskv
Posts: 10
Member Since:
2007-01-19
I dont care how the Linux

I dont care how the Linux memory management works... I know all about that. I still want to be ABLE to flush the cache once in a while. Is that so hard to grasp?

Is there or is there not a way to do this without rebooting?



eselliso
Posts: 3
Member Since:
2006-10-15
Memory Cache

I have the same request - is it possible to flush the cache without rebooting.



KodaK
Posts: 1885
Member Since:
2006-06-14
Quote: I dont care how the
Quote:
I dont care how the Linux memory management works... I know all about that.

Obviously you do not. The Linux kernel does not provide any facility to manually flush the cache. It's unnecessary to do so because of the way the memory management works.

If you are running out of real memory (IE, your system is swapping excessively) then you have a problem and you need to investigate, but the system using all of your otherwise unused memory as cache is not harming anything and it does that by design. There is no fix because it is not broken. If your particular system is behaving differently then you need to give more information -- it is not the cache that is your problem.

If you are actually having RAM issues then I suggest you run top and sort by memory usage to find where your hogs are.

--

WARNING: I no longer actively participate in these forums. My thoughts on trixbox in a nutshell: http://www.youtube.com/watch?v=q4xBMkWu1pE Use AsteriskNOW instead.



KodaK
Posts: 1885
Member Since:
2006-06-14
Quote:
Quote:
If everything is OK it should be Green all the time.

Haha, ok, I see what you guys are fussing over.

In that particular picture you do not have an issue. You are using 0 swap. Whoever coded that app made a mistake making the memory red, because a Linux system will always, always, always use as much RAM as it can for cache. You can safely ignore this, and you might even consider filing a bug or pestering kerry and/or andrew.

You're only using 33% of your "real" RAM. That and the amount of swap being used are the only things to be concerned with.

--

WARNING: I no longer actively participate in these forums. My thoughts on trixbox in a nutshell: http://www.youtube.com/watch?v=q4xBMkWu1pE Use AsteriskNOW instead.



fasarnat
Posts: 3
Member Since:
2008-01-22
a solution,

a solution, here
http://www.ubuntu-unleashed.com/2008/04/free-up-cache-memory-in-l...

and here
http://www.linuxinsight.com/proc_sys_vm_drop_caches.html

the command to launch is this:
echo 3 > /proc/sys/vm/drop_caches

This command, is able to free my cached memory ;)

I have the problem of cached memory grow and grow, on trixbox ce 2.6.0.0, Kernel Version 2.6.18-53.1.4.el5 (SMP)
Distro Name CentOS release 5.2 (Final)



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.