32 bit jvm on a 32 bit RHEL PAE system - java

I have a RHEL 6 32 bit system installed in a 64 bit hardware. The kernel version is,
2.6.32-431.17.1.el6.i686
I posted a very detailed question and answer here. Now, I have the JVM which is also 32 bit. I believe even if I install a 64 bit JVM, I will be allowed to use only upto 3 GB since I have only 32 bit OS.
So, my question is, a single process can have more than 4 GB memory and still be used in a 32 bit system. In a similar manner, if I set my maximum heap size to 2 GB in the 32 bit OS, will I still be able to use the memory?
For instance, if my java application requires 10 GB memory, and I set the maximum heap size to 2 GB, my question is, once the 2 GB is exhausted, will my application terminate or swap the address space and continue working?
I am also interested in knowing a good limit on the maximum heap memory limit.

> I believe even if I install a 64 bit JVM,
No, you can't do this. You can only run 32 bit applications on a 32 bit linux OS - even if the underlying hardware is 64 bits.
> a single process can have more than 4 GB memory and still be used in a 32 bit system.
No, a 32 bit linux installation only supports 32 bit applications, and that means you're limited to an address space of max 4GB. For linux, the kernel needs 1 GB of that space. Native libraries, stack space and other things also needs a piece of the address space, leaving you with memory available for the heap of around 2-2.5GB.
The PAE feature enables the OS to utilize more than 4GB of memory in total, but individual processes are still limited to 4 GB of address space.
> if my java application requires 10 GB memory, and I set the maximum heap size to 2 GB, my question is, once the 2 GB is exhausted, will my application terminate
Yes, if the application needs more memory, it will terminate with an OutOfMemoryError
> I am also interested in knowing a good limit on the maximum heap memory limit.
There is no universal answer - it depends on the application and whatever else you want to run on your system.

I believe even if I install a 64 bit JVM, I will be allowed to use only upto 3 GB since I have only 32 bit OS.
You can install it, but it won't run. Only a 64-bit OS can run a 64-bit application, whether it is a JVM or any other program.
So, my question is, a single process can have more than 4 GB memory and still be used in a 32 bit system.
Not directly. A 32-bit program can only use about 1.5 to 3 GB direct depending on the OS. A program can use a disk cache which is much larger. It can also use other program which themselves use more memory (in total)
In a similar manner, if I set my maximum heap size to 2 GB in the 32 bit OS, will I still be able to use the memory?
If you have a 2 GB heap this should be fine so long as the process doesn't exceed how much memory your whole process can use. The heap is not all the memory used of course.
if my java application requires 10 GB memory, and I set the maximum heap size to 2 GB, my question is, once the 2 GB is exhausted, will my application terminate or swap the address space and continue working?
If you need more than 10 GB, you should ensure you have at least 12 GB of main memory AND a 64-bit OS. What will happen if you don't have enough will range from the program running very slow, or your program crashing, or in extreme cases your whole machine will practically stop.
Java applications run very badly once they start swapping. They either crawl to a stop, or they can practically stop the machine.
I am also interested in knowing a good limit on the maximum heap memory limit.
A good limit is less than your main memory size. The default limit for the server JVM is 1/4 of main memory. Without more information, I would leave it as it is.

Related

Maximum Heap Size of java is too small

I am using a 64 bit Windows 10 system with 32Gb of RAM. One of my 32 bit java application requires a lot of memory so I decided to change the minimum heap size to -Xms4096m at the runtime parameter field in the java configuration dialogue.
However, I soon realised that it would not do anything because apparently my system's maximum heap size is only 247.50mb (which is way too small for a 64 bit system). I am using a 32 bit java so I am expecting a max heap size of around 4GB. Can anyone tell me what determines the maximum heap size and how do I change it?
UPDATED: I understand that the maximum I can allocate is 2GB for a 32 bit system. So my question now is how come for my system, its only 247.50mb?
BELOW ARE MY Java Settings:

JVM - How much RAM should I allocate

I didn't find a suggestion on how much RAM I actually should allocate to the JVM.
Assuming that my computer has 4GB RAM and runs Windows 10. I nearly only use Java Applications on it. With how much RAM should I start the JVM? The system needs RAM for itself too, so in my logic, I should not allocate 4 GB even if that is possible.
This isn't a black/white question, I just want to have an idea and how to come to an answer in this question.
I didn't find a suggestion on how much RAM I actually should allocate to the JVM.
The JVM has a default setting of 1/4 of main memory. If you have 4 GB it will default to 1 GB.
Note: this is a pretty small system and you get get some embedded devices and phones which this much memory.
If you can afford to buy a little more memory it will make your life easier.
I nearly only use Java Applications on it. With how much RAM should I start the JVM?
Unless you have a reason to change a command line parameter I would leave it as it is.
Note: you OS will need some memory, perhaps 1 GB and you want to leave 1 GB free for caching etc, so you could increase the heap size to 2 GB, but only if you needed to.
What if I run 4 programs in parallel? Can I still allocate 2GB for every of that program?
Yes, but it's a very bad idea. You application will start swapping and your computer can become unusable. I would try to stay under 2 GB total for this machine.
We have a business application here that often reaches to the maximum allocated Ram, which makes it lag a lot if a user has too many "tabs" open.
In that case, you should make sure you have the right tool for the job which means making sure your system has enough memory. 4 GB of memory costs $18. If you had a hobby PC with 4 GB, I would say, get more memory. Three years ago, my 8 year old son when he turned 8 I gave him a PC with 8 GB of memory because it's didn't make sense to buy less. I would just get 16 GB or 32 GB minimum. Then its worth spending some time tuning it, maybe.
you can type "jconsole" or "jmc" in command line to see how much memory java used.

Using 32 bit Java in 64 bit Windows

I am using 32 bit version of Java in windows 7 64 bits. The system has a RAM of 6 GB. But when JVM is allocated memory by OS, it doesnot goes beyond 1.5 GB (same as in 32 bit OS). What are the possible reasons, that JVM is not allowed sufficient memory. And if possible how to fix it? I cannot upgrade to 64 bit JVM.
A 32-bit process on Windows is still subject to the same limits as running on a 32-bit Windows OS. See the answers to this question.
How much memory can a 32 bit process access on a 64 bit operating system?
This guidance from Oracle suggests that a 32-bit JVM can use approximately 1.5GB.
The maximum theoretical heap limit for the 32-bit JVM is 4G. Due to various additional constraints such as available swap, kernel address space usage, memory fragmentation, and VM overhead, in practice the limit can be much lower. On most modern 32-bit Windows systems the maximum heap size will range from 1.4G to 1.6G.
As indicated by this article:
The default maximum heap space is 1/2 of physical memory of size upto 192 bytes and 1/4th of physical memory for size up to 1G.
I know you have more than 1G, but maybe this also applies for you
32 bit application will not be able to use more that 4GB of RAM. In practice, it will not be able to use more than 3GB because it needs some virtual memory space reserved for operating system.
Besides that, by default JVM allocates up to a quarter of available RAM. If you want to override this use option:
java -XX:DefaultMaxRAMFraction=1
It should use all available RAM that is feasible for 32 bit application.
Source: http://jvm-options.tech.xebia.fr/#
To be able to use more memory you have to upgrade to 64 bits. Unfortunately a 64 bit JVM cannot load 32 bit dlls, so the calls to the dll must be made from a different process, and you have to use an rpc mechanism to talk with the process instead of using the dll directly. It's a lot. of work but it can be done.

Is there a upper limit to how much heap size JUnits can use

My Jenkins build is running out of memory because of JUnits. When I try to give it (the JUnits) more than 4GB it errors out. I am using Linux as my build machine.
Invalid maximum heap size: -Xmx4096m
I am just wondering, is there a upper limit to how much heap size JUnits can use?
"For a 32-bit process model, the maximum virtual address size of the process is typically 4 GB, though some operating systems limit this to 2 GB or 3 GB. The maximum heap size is typically -Xmx3800m (1600m) for 2 GB limits), though the actual limitation is application dependent. For 64-bit process models, the maximum is essentially unlimited."
Found a pretty good answer here:
Java maximum memory on Windows XP
Memory is allocated to JVM not JUnit or any other class.
and there is limit on 32-bit system to assign max of 4Gb but if you requires more memory then move to 64 bit machine as there is no limit of max memory allocation .
i would guess you are using a 32 bit jvm ..
check this post:
Maximum Java heap size of a 32-bit JVM on a 64-bit OS
It's not JUnit but JVM. 4GB heap is too much for 32-bit JVMs.

Max memory for 64bit Java

What's the maximum amount of heap space that one can allocate for java on a 64-bit platform? Is it unlimited?
Theoretically 264, but there might be limitations (obviously)
According to this FAQ it's only limited by memory and swap space on the local system:On 64-bit VMs, you have 64 bits of addressability to work with resulting in a maximum Java heap size limited only by the amount of physical memory and swap space your system provides.
See also Why can't I get a larger heap with the 32-bit JVM?
Also keep in mind you need to set the max heap via command line. Without an -Xmx command. without it Java uses 64mb + 30% = 83.2mb as a default max heap on 64 bit machines according the same FAQ.
java -Xmx1000g myClass
works fine on my machine. But it dosn't seem to yet support the 't' modifier so you can't specify max memory in terabytes yet :)
If you could make every atom in the universe into a byte of RAM, you could allocate it in a 64 bit address space.
Actually, that's a slight exaggeration.
There are 10^80 atoms in the universe (according to WolframAlpha), and 2^64 bytes of address space in a 64 bit system, so you'd only be able to address 1 out of every 5x10^60 atoms. But if you have 18 qintillion bytes of RAM, you'd probably need a couple of quantum black holes to power it with.
This probably depends on the system your VM is running in. If you are running a AMD x64 architecture the address space of currently shipped processors uses 48 Bits, not 64. This results in a theoretical maximum of roughly 256 TB. (See http://en.wikipedia.org/wiki/X86-64)
I am not a specialist in VMs, but any modern OS typically will give as much memory as there is physical RAM plus available virtual memory. Probably thats what the VM will pass to your application depending on its configuration.
With recent VMs from Sun, the practical heap limit size is usually 512 times the available physical and/or virtual memory. Even if the theoretical limit is much higher, the VM will allocate 1 byte for maangement purposes for each 512 bytes of heap memory on startup, so 1TB of heap will immediately require 2GB for the memory management.
In theory its between 2^63 and 2^64 bytes.
In practice it is limited by the amount of physical memory and swap space available on your machine. And the physical memory is in turn limited by your chipset (i.e. the number of address pins on the physical memory address bus) and motherboard (i.e. the number and size of the DIMM sockets).

Categories

Resources