hossein shemshadi
hossein shemshadi

Reputation: 303

Is it possible to increase a java process's(when is running) size?

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)?

Upvotes: 6

Views: 3504

Answers (3)

Shraddha
Shraddha

Reputation: 1052

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 !!

Upvotes: 1

Peter Lawrey
Peter Lawrey

Reputation: 533492

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.

Upvotes: 6

Naresh kumar
Naresh kumar

Reputation: 1069

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.

Upvotes: -1

Related Questions