What are the reasons that max jvm heaps are not sized up to or close to the max physical memory on a machine?
Asked Answered
A

1

7

I have a 64 bit machine, theoritically the address space is 2^64 bytes and it has 32 G of physical RAM.

this is a server scale machine with 16 cores and is a production server.

Since there is no other process running that consumes mass amounts of memory and the server jvm is the only app thats running, is there any reason to not set the jvm heap to a really large number ?

I am seeing it being set to less than 10 gigs and there is no explanation that I can think of this could be.

As I mentioned earlier in the post: I understand that the kernel, cache and other processes would need to share RAM. But barring any other processes and OS native stuff, there is nothing else going on. this machine is a production machine and solely for this specific jvm.

Would there be any reason to not set to to something like 20 gigs/32 g (physical ram) ?

From the comments below- it appears not...other than the need to fail fast, thanks for your inputs

Asseverate answered 6/12, 2013 at 17:21 Comment(6)
In my own experience, there's usually more than one JVM on a physical machine, at least for the typical user. And most of them don't need more than say 1-2 gig. So I wouldn't be surprised this has lead to the default values you observe.Dissociation
To add to C4stor's comment: If your application needs the RAM, jack the number up. People often lower it because the application will only use tons of RAM in some sort of a "runaway" state and they'd like it to fail early instead of hogging RAM and failing later.Sheared
Well in your particular case, given that your assumption is valid, and more to the point remains so, you could choose to up the limit. In most other situations people would be asking what ijit sized the VM and used up all my &*^*&*( memory.Govea
Additionally, there are frequently things other than the JVM itself running. So you have 32G on a 64-bit machine; that's entirely plausible for a development workstation these days. The JVM would need to share with the desktop environment, the IDE, the web browser, possibly a database... It's better for it not to make the assumption it has the whole machine and to let the user specify if it does. (Additionally, some systems like Neo4J use significant amounts of RAM outside the JVM heap anyway.)Epistyle
JVM itself needs physical memory for its' bookkeeping, so you can't give all RAM to Java heap, you must leave something for JVM at least.Oxygen
Because sometimes there's something else to do? Besides, sometimes performance goes down as the heap grows larger, as GC must manage more objects. There's generally a "sweet spot" above which adding heap does no good and may do harm.Goodill
C
1

Because the operating system also needs RAM, for cache, buffers, daemons such as syslogd, page tables, kernel data structures etc.

Also, the JVM designers have no idea what other applications you might want to start after the JVM starts up. So it is sensible for the JVM to not hog all the RAM by default.

Centre answered 6/12, 2013 at 19:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.