File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Java Heap Size Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java Heap Size" Watch "Java Heap Size" New topic
Author

Java Heap Size

Sujoy Choudhury
Ranch Hand

Joined: Sep 17, 2008
Posts: 136

Does anybody know any good material to read regarding Java Heap Size?
How and why does Java Heap Size matter on a 32bit/64bit machine?
I want to know these in details.


Thanks and Regards,
~Sujoy
Matt Cartwright
Ranch Hand

Joined: Aug 25, 2008
Posts: 149

I think you might consider studying the Garbage Collector algorithms...
That's the one that cleans up your heap.

Depending on your Java application (e.g. standalone or in a JEE container) the requirements
for heap size vary and Garbage Collector algorithms have to be different.

Unfortunately the algorithms and the structure of the heap is vendor specific. Or better,
product specific with Oracle owning HotSpot and JRockIt...

On some platforms like HP-UX and AIX you even have to use what their vendors understood
could be Java.

And then you rightly add the 32-bit and 64-bit issue

So, what incarnation of Java (JVM implementation) are you using?

Look for the Garbage Collector tuning manual and performance tuning in general.
Welcome to the 'young generation' or 'nursery', if you don't get dereferenced you
will be promoted

Sujoy Choudhury
Ranch Hand

Joined: Sep 17, 2008
Posts: 136

Hi Matt,
Thanks a lot for your reply.

Well, I guess, I should re-phrase the question.
All I want to know providing the -Xmx non-standard option, why do we want to know whether the underlying machine is 32/64 bit?
Maybe, to ask more precisely, in a 64bit machine why can't I give more than 2gb memory(If I have say 8gb RAM) to -Xmx option?
This is what I had heard from somewhere, but I want to know the reason.

Sorry for the confusion earlier.
Matt Cartwright
Ranch Hand

Joined: Aug 25, 2008
Posts: 149

alrighty, so what hardware/OS/JVM combination are you using?

In most Operating Systems running on a 32-bit architecture, processes are limited to
less than 2GB total memory. This includes the Java heap, the process' heap and stack,
the memory used by JNI (if any), the thread stacks and other internal structures.

On a Sun Fire V440 w/ Solaris 9 and HotSpot JRE 5.0 the 32-bit heap limit is 4.3 GB.

In Linux (e.g. RHEL 4.0 and later) you can run a hugepage kernel and
JRockIt which gives a max 32-bit heap size of 2.7GB.

On MS Windows you can try something like /3GB or /PAE with JRockIt, but due to
the fact that the heap needs to be in consecutive memory, you'll end up with a heap
size of less than 2GB.


What about 'java -d64 -server -Xms8000m -Xmx8000m -Xmn4000m' ?
That sets the min and max heap size to 8GB and the new size to 4GB, resulting in
(almost) 4GB 'young generation' space and (almost) 4GB 'old generation' space.
Any of them clearly more than 2GB.

HTH
Matt
Sujoy Choudhury
Ranch Hand

Joined: Sep 17, 2008
Posts: 136

Thanks a lot Matt for your detailed answer. I do have more stupid questions for you.

alrighty, so what hardware/OS/JVM combination are you using?

I have Window 7 64bit, 6GB RAM, intel core i7 with Oracle JDK1.6.0_26 (Java HotSpot)
Well, its not about my machine. I want to know the fundamental details.


In most Operating Systems running on a 32-bit architecture, processes are limited to
less than 2GB total memory. This includes the Java heap, the process' heap and stack,
the memory used by JNI (if any), the thread stacks and other internal structures.

On a Sun Fire V440 w/ Solaris 9 and HotSpot JRE 5.0 the 32-bit heap limit is 4.3 GB.

In Linux (e.g. RHEL 4.0 and later) you can run a hugepage kernel and
JRockIt which gives a max 32-bit heap size of 2.7GB.

Why there is a limit here in different types of machines?
Did you mean even if that machine has 6/8GB RAM, you still can't give more than the specified total memory to one single JVM?

What about 'java -d64 -server -Xms8000m -Xmx8000m -Xmn4000m' ?
That sets the min and max heap size to 8GB and the new size to 4GB, resulting in
(almost) 4GB 'young generation' space and (almost) 4GB 'old generation' space.
Any of them clearly more than 2GB.

What is -d64 here? and also is this -Xmn a JRockit standard?


I think I should ask you one more important question that,
is there any RAM restriction for 32 / 64 bit type of machines?
Say, 32/64 bit machine can't or can have 12 GB RAM.

Please shed some light.




Matt Cartwright
Ranch Hand

Joined: Aug 25, 2008
Posts: 149

Well, its not about my machine. I want to know the fundamental details.

Maybe a good starting point is Java SE HotSpot at a Glance
Sorry, don't know any books...

Why there is a limit here in different types of machines?

Different platforms (x86 based, 68k based, SPARC, RISC, CISC, etc.) use different memory models.
Typically this would be one out of Flat, Paged (e.g. PAE) and Segmented (not talking NUMA or Cluster here).

Did you mean even if that machine has 6/8GB RAM, you still can't give more than the specified total memory to one single JVM?

That is correct, depending on the combination of architecture and Operating System.
For example, Linux (e.g. x86 and x86-64) and Solaris (SPARC) are using a Flat Memory Model.

What is -d64 here? and also is this -Xmn a JRockit standard?

Those are standard JVM command line options, neither HotSpot nor JRockIt specific.
Maybe reading some documentation helps...

I think I should ask you one more important question that,
is there any RAM restriction for 32 / 64 bit type of machines?
Say, 32/64 bit machine can't or can have 12 GB RAM.

You can install as much memory as you like
Questions then are:
Does the chip set support it?
Can your OS address it all and make us of it?
Sujoy Choudhury
Ranch Hand

Joined: Sep 17, 2008
Posts: 136

Thank you very much Matt!
I really appreciate it.
You have cleared many doubts.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Heap Size