Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to dynamically change maximum java heap size?

I know you can set max heap size at startup using -Xmx but is it possible to change it dynamically during runtime?

Is there any tool or (undocumented) api which will allow me to do that?

like image 527
pdeva Avatar asked Jul 07 '09 10:07

pdeva


People also ask

Is heap size dynamic?

Heap memory is dynamic, like stack memory, in that it is allocated at run time.

Is Java heap dynamic?

Heap space is used for the dynamic memory allocation of Java objects and JRE classes at runtime. New objects are always created in heap space, and the references to these objects are stored in stack memory. These objects have global access and we can access them from anywhere in the application.

How do I increase allocated heap size?

1)Change the gradle. properties file and change the heap size as per your requirement. 2)"Edit Custom VM Options" from the Help menu. It will open studio.


2 Answers

No, it is not possible.

like image 51
Marko Avatar answered Nov 14 '22 22:11

Marko


Once the memory structure is fixed it cant be changed

like image 28
Umair Ahmed Avatar answered Nov 14 '22 21:11

Umair Ahmed