I have a very important process running. I can not stop it and need to enlarge the java process' size! Is there any way to increase my java process' size online(at runtime)?
-
2What do you mean by "process' size"? Heap size? Stack size? – kraskevich Dec 31 '14 at 08:52
-
I mean both of them. – hossein shemshadi Dec 31 '14 at 08:55
-
How do you know you need to increase the "process size"? Are any errors encountered or are you just observing the system / heap usage and are worried that it's getting "full"? – Michael Dec 31 '14 at 08:55
3 Answers
You can increase the following during a running process.
- number of threads
- amount of memory used by the stack (but the maximum size of an individual stack)
- amount of native memory used
- amount of memory mapped files mapped into memory
- shared libraries.
But what you can't do is increase the maximum heap size. This is what a maximum means. More technically it is because the entire heap must be a single continuous region of memory and increasing the limit wouldn't help.

- 525,659
- 79
- 751
- 1,130
-
2When you say *increase*, you mean *access more of this* resource right?. – TheLostMind Dec 31 '14 at 09:01
-
@TheLostMind yes, more of these will increase the process'es size. – Peter Lawrey Dec 31 '14 at 09:06
-
1Was just confirming that :).. So, we can't *explicitly* ask for an increase in native memory or stack right?. The OS *increases* the size of the process by allocating memory as and how it sees fit. right? – TheLostMind Dec 31 '14 at 09:09
-
2@TheLostMind we indirectly increase the process size by asking for more memory. There isn't a native process limit we need to increase. – Peter Lawrey Dec 31 '14 at 09:12
-
1@TheLostMind BTW the maximum direct memory limit is a field in the `Bits` class which you can read / alter while the process is running ;) – Peter Lawrey Dec 31 '14 at 09:13
-
The command line argument -Xmx sets the maximum Java heap size (mx). All java objects are created on the Java heap, but the total memory consumption of the JVM process consist of more things than just the Java heap. A few examples:
- Generated (JIT:ed) code
- Loaded libraries (including jar and class files)
- Control structures for the java heap
- Thread Stacks
- User native memory (malloc:ed in JNI)
It is important to think of this when dimensioning how many processes that should run on a single server and what to set maximum heap size to. Usually the heap is by far the largest part of the process space, but the total size of the process will also depend on your application.
Reserved != Committed
It is easy to be alarmed by the number for reserved (or mapped) memory, but a process will not use any physical memory resources until it memory is committed.
So I would suggest you not to increase -Xmx size but to follow the solution provided by Peter Lawrey !!

- 1,052
- 11
- 22
You can increase heap size but that configuration is depend on IDE. Eg : for eclipse edit eclipse.ini has
-Xms<size> - 2048m
-Xmx<size> - 2048m
depending on your RAM size.
Hope this helps.

- 1,069
- 1
- 7
- 21