0

Before posting this question I have gone through post java increase xmx dynamically at runtime but answer given to this question not making me satisfy to know the reason.

I have an java application which takes a encrypted and compressed json string from an ESB server then application decrypt and uncompress the json string to a list of object. We published java application with Xms 256m and Xmx 720m but still sometime we get OutOfMemory exception cause to exception is while decrypt and uncompress the string all the memory get filled. lots of code review and optimization are done but as we don't have control on data sent by ESB sometime time it may be just of KBs and sometime may of MBs.

In this case dynamically increasing the memory will help.

I know there is no option to increase Xmx dynamically, but why? and about answer :

To prevent JVM from consuming the entire machine's free memory.

If machine having free memory then why not to use it?

Community
  • 1
  • 1
Amogh
  • 4,453
  • 11
  • 45
  • 106
  • Cf. http://stackoverflow.com/questions/4789280/programatically-setting-max-java-heap-size – Anders R. Bystrup Jun 07 '15 at 19:49
  • @AndersR.Bystrup, according to answer we have to relaunch the application in new JVM with new memory but relaunching the application will destroy all the work done is done in current instance – Amogh Jun 07 '15 at 19:52
  • 2
    You can define a sane maximum of memory you want to give to your JVM, then it can grow until it reaches that maximum. Depending on your hardware and the JVM you use can can assign several GB. But if someone "evil" can send you huge JSON to crash your application you should perhaps try to "guess" the size of the received JSON and abort processing before it can do any harm to your program. Did you already check if your program suffers from a memory leak ? – Marged Jun 07 '15 at 20:03

0 Answers0