swap used up , even though RAM free
Hello Everyone.
can somebody will help me in understanding the swap memory concept. As in my application i have seen that swap memory is getting used fully even when the Free space is available in RAM. My understanding was swap wil be used only when there is RAM crunch issue.. Kindly suggest why space is used fully , any article,link will be of great help My application setting RAM- 10 G SWAP 3 G |
First of all, how do yo know that your Swap space is being used?
Also mention your Distribution. |
I checked the swap usage using free -g command
uname -a Linux localhost.com 2.6.18-128.1.6 Mar 24 12:05 2009 x86_64 x86_64 x86_64 GNU/Linux cat /etc/issue linux64-5.3.2 |
Use "free" with -m parameter and list the output here.
You should try the command "swapon -s", and also list the output. For details, refer "man swapon". As I studied, Swap is outside the control of the user and is managed by the kernel. So you actually cannot find the solution. Your swap may be used only because your system cannot use more RAM. |
The Linux kernel usually swaps out some not RAM that is occupied by applications that are not used for a long time to use that RAM as cache to speed up the system. So even on systems with high amount of RAM you can sometimes see a few MB of used swap although there is plenty of RAM.
This is normal behavior, I wouldn't bother about that. |
The OP did say (my emphasis)...
Quote:
|
Sorry, seems that I have overlooked the "fully" part.
|
"My understanding was swap wil be used only when there is RAM crunch issue"
I would have thought that too but seems there are some other factors going on. I researched this a bit a while ago. Seems that what you say can happen under some issues and to make things worse the swap doesn't flush parts. The cure is not an exact cure. One part is to see if the app is locking up swap bit by bit or is it a one time shot that goes to swap. I'd maybe start by changing the swappiness of your swap. If this application just can't be fixed or figured out you might end up using a combined swap of multiple to act like a swap raid. Might end up having to force swap to clear based on time or metric. |
Quote:
Linux does not pull pages back from swap until they are accessed again. So if memory was used and then freed, you might leave a lot of swap space in use. If you do have a problem, it is likely a memory leak in some process. To further investigate that, you would need to look into those processes with high virtual memory use and then look into whether that use is "anonymous" (possible memory leak) vs. file mappings (which don't contribute to swap usage). Quote:
If there is a memory leak or other problem, you need to start by identifying the problem processes, then deal with it or ignore it based on understanding what those processes are doing. But "deal with it" will not involve either of those methods of attacking the symptom. |
All times are GMT -5. The time now is 12:48 AM. |