Results 1 to 3 of 3
Hi, I am a java programmer having little knowledge on linux. We have one java application polling continuoulsy on a Queue. For every 15 mins, it will process a transaction ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 09-13-2011 #1
- Join Date
- Aug 2010
Memory utilization on linux server
I am a java programmer having little knowledge on linux. We have one java application polling continuoulsy on a Queue. For every 15 mins, it will process a transaction involving data extraction from a 120 MB file. When we ran this application on unix (HP-UX) server, below is the memory utilization pattern on this server.unix.jpg
When we ran the same application in Redhat Linux server, below is the memory utilization pattern. linux.jpg
In Unix the max memory utilization was around 400 MB and in Linux for the same application and data it has reached 2.5 GB incrementally.
From the application perspective we are not seeing memory leaks as it is occupying consistent memory in unix.
Is there any settings on linux server side which will do a clean up of memory at regular intervals?
Are there any parameters which needs to be set on linx which impacts the memory utilization of the applications?
- 09-13-2011 #2
- Join Date
- Dec 2009
This is a loaded question. Can you tell me how you are measuring memory utilization on Linux?
A lot of people use "top" and look at the Mem: line. This is completely incorrect. On my server, the line currently shows:
Mem: 2074968k total, 1795608k used, 279360k free, 159808k buffers
So, 2 GB total, 1.7 GB used! That's horrible you might think, but it's not. because of the next line....
Swap: 2031608k total, 732k used, 2030876k free, 851864k cached
Linux uses any excess memory to build a cache. That memory is available to be used by programs at anytime.
You can force Linux to relinquish all the "clean" data in the cache.
# echo 1 >/proc/sys/vm/drop_caches
When I do that, have a look what happens.
Mem: 2074968k total, 884364k used, 1190604k free, 372k buffers
Swap: 2031608k total, 732k used, 2030876k free, 105560k cached
Notice that the 1.7 GB used has shrunk to only 884 meg.
You say that this is a java program. What parameters are you using for heap size, etc. Different jvms have different garbage collection algorithms. This is especially true if you switch from IBM java to Sun java.
- 09-14-2011 #3
- Join Date
- Nov 2008
- Tokyo, Japan
JConsole" to track the memory usage of the Java virtual machine, which gives a fairly accurate indication of how much memory has been allocated by the application.
I don't think you need to worry too much. If the operating system signals the Java virtual machine that it is using too much memory, the Java virtual machine will automatically trigger a garbage collection. Otherwise, it will use as much space as it is permitted -- and it runs much faster this way. Increasing garbage collection cycles can slow down your application a lot. The factory default memory usage configuration should be optimal for your operating system and application as it is.
However, you can tune the performance of garbage collection with command line arguments when invoking the Java virtual machine. Which version of the Java virtual machine are you using? Are you using the binary provided by Oracle, or some other implementation? If you are using Oracle, these flags (listed here) can be set on the command line to instruct the virtual machine how often it should run garbage collection. I also recommend you read the garbage collector documentation (linked here).
If you are using the Oracle (Sun) Java VM, I think you want to set the -XX:MaxNewSize=bytes flag. The virtual machine has a permanent stack which is always allocated, and a second "new generation" for allocating objects between garbage collection generations. You can limit the new generation size to force garbage collection to occur more often.
But like I said, this value is already set to the optimal size for your operating system, so don't worry too much about memory usage. Even if it does go to several gigabytes, the system will take steps to slow its allocation if resources become scarce.