Reputation: 183
Running my java application takes more memory on my new rhel62 machine. The same program takes less memory on rhel55.
i wrote a very simple 'HelloWorld' java program, and run it. That too takes huge memory in rhel62. I am using Java_1.7 in both Rhel55 and Rhel62
import java.io.* ;
class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!"); // Display the string.
Console console = System.console();
String input = console.readLine("Enter ...:");
System.out.println(input);
}
}
$ /usr/java/jdk1.7.0_09/bin/javac hello.java
$ /usr/java/jdk1.7.0_09/bin/java HelloWorldApp
Hello World!
Enter ...:
Java application on top command
rhel62 : Linux qaatestp 2.6.32-71.el6.x86_64 #1 SMP Wed Sep 1 01:33:01 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
5069 qaatestp 20 0 5557m 18m 7604 S 0.0 0.1 0:00.11 java
31719 qaatestp 20 0 105m 1972 1468 S 0.0 0.0 0:00.35 bash
rhel55 : Linux qa2testp 2.6.18-238.5.1.el5 #1 SMP Mon Feb 21 05:52:39 EST 2011 x86_64 x86_64 x86_64 GNU/Linux
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
18065 qa2testp 17 0 2400m 14m 7508 S 0.0 0.2 0:00.22 java
17244 qa2testp 15 0 66196 1784 1232 S 0.0 0.0 0:00.81 bash
I have no idea why this behaves this way in rhel62, because of this i am facing unnecessary problems. Is this Linux rhel6.2 issue ? or Java issue? or No issue? :)
I thought of raising this here before asking the support teams. Please give your suggestions?
Upvotes: 1
Views: 2608
Reputation: 183
Thanks Very much for reply.
This is because of memory allocation changes made on Rhel6. RHEL6 is allocating separate chunks of memory for each thread. In multicore processor, this will improve the performance, with memory overhead. There is an environment variable MALLOC_ARENA_MAX, setting this value as 1 is reducing this memory allocation. Please see the following link for more details.
Linux glibc >= 2.10 (RHEL 6) malloc may show excessive virtual memory usage
Thanks
Upvotes: 4
Reputation: 533510
Java by default sets a maximum heap size which is 1/4 the main memory size on startup. the more memory you have the more virtual memory it will allow itself on startup. note, this doesnt mean it will use more resident memory but often means it will.
at a guess, your old machine has 12 GB and your new one has 24 GB.
Upvotes: 0
Reputation: 116177
You should not take a quick judgment just by looking at VIRT
column - it simply means that this much virtual memory was allocated. This virtual memory may be never actually accessed.
However, pay close attention to RES
(resident) and SHR
(shared) memory columns. In your case, difference is not that big: just 14MB vs 18MB for resident memory, and essentially the same for shared.
Upvotes: 2