Reputation: 45
Can anyone explain me, how heap space will allocate if three java applications runs on a same machine.?
Whether each JVM allocates separate heap space.? else it will be common for three applications.?
Thanks in advance.
Upvotes: 1
Views: 170
Reputation: 36304
The OS allocates a certain amount of space to the JVM... It is left to the JVM to allocate that memory to the different threads(I dont want to say processes) under it... U can change the amount of memory to be given to each thread under the JVM, but its not guaranteed to work.. Its the JVM's call finally. Increasing the memory size is just a hint to the JVM - telling it - "bro! this thread needs more memory... Try allocating it."
Upvotes: 0
Reputation: 48682
Each JVM has its own "heap space", in the sense that each JVM has its own virtual address space that it uses for its heap. From the perspective of each JVM, it has its own memory space that only it accesses.
Behind the scenes, however, it its a little bit more complicated. The private memory space of each JVM is an illusion created by the virtual memory system of the operating-system kernel. In practice, all the programs running on the computer must share the (perhaps limited) RAM that is available. So the JVMs are competing for the available RAM. To the degree that the "heap space" is part of the RAM, the heap spaces are not separate. In particular, if one JVM runs a greedy application that uses lots of heap space (and thus lots of RAM), so the total working set of the JVMs exceeds the RAM, all the JVMs will slow down.
Upvotes: 0
Reputation: 4398
Every JVM will have its own heap memory (and every heap memory will contain a lot of objects). You can look to this article for further clarification: http://javarevisited.blogspot.com.es/2011/05/java-heap-space-memory-size-jvm.html
Upvotes: 1