?
Solved

Two applications with -XX:+AggressiveHeap on same server

Posted on 2006-06-29
14
Medium Priority
?
1,268 Views
Last Modified: 2012-06-27
I have two Java applications running as daemons on the same server, which match the description in http://java.sun.com/docs/hotspot/gc1.4.2/#4.2.2.%20AggressiveHeap|outline of being "long-running, memory allocation-intensive jobs".

I read:

> The size of the initial heap is calculated based on the size of the physical memory and attempts to make maximal use of the physical memory for the heap (i.e., the algorithms attempt to use heaps nearly as large as the total physical memory).

How can I get the JVM to attempt to use heaps nearly *half* as large as the total physical memory so I can get both of the applications running optimally? [There is 8G of RAM in the server.]
0
Comment
Question by:rstaveley
  • 7
  • 7
14 Comments
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 17007929
Try using -Xmx4000m in both servers - makes JVM to comsume max memory upto 4G
0
 
LVL 17

Author Comment

by:rstaveley
ID: 17007941
> Try using -Xmx4000m

Combined with -XX:+UseParallelGC, would that give me everything that -XX:+AggressiveHeap that I can benefit from for my two applications?
0
 
LVL 17

Author Comment

by:rstaveley
ID: 17007947
Let me re-phrase that...

Combined with -XX:+UseParallelGC, would that give me everything from -XX:+AggressiveHeap setting that I can benefit from for my two applications?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 23

Accepted Solution

by:
Ajay-Singh earned 1000 total points
ID: 17007957
sure it would. Since you are running 2 applications on the same server, try add option too

-XX:ParallelGCThreads=2

It would run 2 threads for parallel GC. By default it runs as many threads a number of cpus on the server.
0
 
LVL 17

Author Comment

by:rstaveley
ID: 17007979
Thanks, Ajay.
0
 
LVL 17

Author Comment

by:rstaveley
ID: 17008045
Curiously, looking at 39. in http://java.sun.com/docs/hotspot/gc1.4.2/faq.html I see...

Two application instances running on a large multi-processor server with 4gb of physical memory. Each java application instance is allocated a part of total system memory by an explicit specification of the maximum and minimum heap sizes.

      #java -server -XX:+AggressiveHeap -Xms1024m -Xmx1024m

It looks like I could combine -XX:+AggressiveHeap with -Xmx4000m after all?!
0
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 17008180
I don't think so. Once the first application hits the limit (4G), the server would do a lot of swapping to allocate memory of another instance. Its recommended
1. start the server with same values of of -Xms and -Xmx
2. these values should be same or little lesser than size of RAM. In your case it would be good to allocate 2G for each application
0
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 17008249
sorry about typo.
read
>limit (4G)
as limit(8G)
and

>good to allocate 2G for each application
as
good to allocate 4G for each application

0
 
LVL 17

Author Comment

by:rstaveley
ID: 17008467
Yes in the FAQ example it was 4G and in my set up there is 8G.

In my 8G set-up, I could do:

nohup java -server -XX:+AggressiveHeap -Xms4000m -Xmx4000m rstaveley.App1 2> /dev/null > /dev/null &
nohup java -server -XX:+AggressiveHeap -Xms4000m -Xmx4000m rstaveley.App2 2> /dev/null > /dev/null &

...leaving 192MB of RAM for for other stuff on the server and get benefits from -XX:+AggressiveHeap, which i wouldn't otherwise get from simply using...

nohup java -server -XX:+UseParallelGC -Xms4000m -Xmx4000m rstaveley.App1 2> /dev/null > /dev/null &
nohup java -server -XX:+UseParallelGC -Xms4000m -Xmx4000m rstaveley.App2 2> /dev/null > /dev/null &

I'm happy to dedicate the RAM to my two applications.
0
 
LVL 17

Author Comment

by:rstaveley
ID: 17009282
For the record, I'm using 5.0 and the maximum heap size is 1G - see http://java.sun.com/docs/hotspot/gc5.0/ergo5.html

nohup java -server -XX:+AggressiveHeap -Xms1024m -Xmx1024m rstaveley.App1 2> /dev/null > /dev/null &
nohup java -server -XX:+AggressiveHeap -Xms1024m -Xmx1024m rstaveley.App2 2> /dev/null > /dev/null &

My application ought to be able to live within 1G, but I'm curious that there is a 1G ceiling all the same.
0
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 17009495
ya, thats default behaviour. But you can alter this by setting max amd min to your custom size

make sure that you add the following also:
-XX:ParallelGCThreads=2
0
 
LVL 17

Author Comment

by:rstaveley
ID: 17009560
> ya, thats default behaviour. But you can alter this by setting max amd min to your custom size

How so? Presumably not with -Xms/-Xmx because 1024m is the maximum permitted according to http://java.sun.com/docs/hotspot/gc5.0/ergo5.html.

> -XX:ParallelGCThreads=2

I didn't follow the logic on this. The server has 4 logical CPUs (2 CPUs with hyperthreading). The automatic setting would be -XX:ParallelGCThreads=4 on the two applications, which seems sensible, because you may as well use any available CPU?
0
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 17009795
On server-class machines by default the following are selected.
Throughput garbage collector
Heap sizes
initial heap size of 1/64 of physical memory up to 1Gbyte
maximum heap size of ¼ of physical memory up to 1Gbyte
Server runtime compiler

The article says this behaviour is by default. and -Xms/-Xmx DOES the magic.

0
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 17009812
> I didn't follow the logic on this. The server has 4 logical CPUs (2
> CPUs with hyperthreading). The automatic setting would be
> -XX:ParallelGCThreads=4 on the two applications, which seems sensible,
> because you may as well use any available CPU?

GC is always CPU bound. So, if you set it to default(no of CPU in your box), then performance would degrade.
So, its good idea to divide equally.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month16 days, 9 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question