Linux Server free memory decreases

Hi,

I am facing one problem, On our Linux server Free memory decreases gradually but my java process memory does not increase.
Please any one tell, why free memory decreases gradually (1MB in approx 15 minutes).

kernel details:-
Linux linux4 2.6.9-42.ELsmp #1 SMP Wed Jul 12 23:27:17 EDT 2006 i686 i686 i386 GNU/Linux

Thanks & Regards,
Vaibhav

it might be that linux uses free memory for caches (it fills up as the server runs).

example:

# free -m

         total       used       free     shared    buffers     cached

Mem: 7985 7798 187 0 145 2493
-/+ buffers/cache: 5158 2826
Swap: 1983 0 1983

This machine has 8gb of ram and is using (2.5GB as cache)

If an application needs this memory it will get it.'

or you might have a memory leak ....

1/ it's most probable that s93366 is right: the memory is not "going away", it's being cached. It will be deducted from the "free", will be added to the "used", it will be in "cached" columns.

2/ Open a second console and use the "top" command. See which processes use most memory, see how much your java uses.

Or give us the output from the free :slight_smile:

Yes On my server cache memory also increases some kbs in each 15 minutes
For eg:- if free memory decreases 600 kb then cache memory increases only 100kb

Please tell what is the reason why cache increases
and any kernel tuning required for this problem.

My java process taking around 2GB memory
oas 13207 85.2 24.6 2566432 2045672 ? Sl Dec03 1076:11 /usr/java/jre1.5.0_15/bin/java

Free output:-
[root@pdclinux4 aux]# free -lm
total used free shared buffers cached
Mem: 8115 2720 5395 0 177 433
Low: 820 218 601
High: 7295 2502 4793
-/+ buffers/cache: 2109 6006
Swap: 8189 0 8189

Please any one give comment why cache memory increases due to this any harm on my system in a long run?

Cache memory is just some nix-trix: instead of "not using" memory your system doesn't need, it will use the memory to "cache data". When an application requests more memory, the kernel will free the cache if needed though, so don't worry, memory used by the cache is actually "available" for your programs.

Your java thing seems indeed to be using 2Gb of memory.. not much more I can say of that. If the java thing grows, then it's probably your java code. If the java thing always uses the same amount of memory, and something else grows, it's something else :')

Hi
run top -i
to see name process have problem
Also see if an files in your repertory tmpfs disk
df to see if mounted and linked directory
Best regards

Hi Vaibhav Agarwal,

Konerak is correct. I ask that question to before. I have 16 GB of RAM in a linux machine and all of a sudden it goes to cache but through researching to forums and website that is just normal. It will allocate available memory to cache so that application can use it.

Have you explore the settings on your JAVA apps regarding setting up memory allocated for JAVA?

Try clearing memory cache - sync; echo 3 > /proc/sys/vm/drop_caches

For a reference with details, see,

Again, while this command works, you only revert the linux philosophy: "idle memory is a waste". Linux puts your unused-memory to use, why would you undo that?

As you said when an application requests for more memory the kernel will release the cached memory but I have seen the case where one Java process needs 2gb memory and around 12gb of heap space got cached and at the same time it is showing around 25mb of free space and application throws java.lang.OutOfMemoryError: Java heap space.

Can you please describe it bit more elaborately?

And also let me know how can be the cached memory release and get used during the execution of process?

Hello Siba,

the kernel will automatically release the cached memory, if available. If java reports an error, perhaps you didn't start the Virtual Machine with the appropriate parameters?

If I recall correctly from my java-days, try launching the VM with the

java -Xms<initial heap size> -Xmx<maximum heap size>

command. Example:

java -Xms128m -Xmx2048m

to allocate 128Mb of memory from the start, and 2048Mb as maximum.

If you're still having problems with java memory leaks, there are toolkits out there to detect leaks in your application. I've never used any, so I suggest you use plain old google.

Happy holidays!
K.