问题
I am having two webapplication running inside tomcat. Java Heap space is allocated for Tomcat and it is shared for both appliaction. In that one application consumes more and other is getting OUT_OF_MEMORY.
Is there any way to set memory settings per web application. Say 70% for one webapp and 30% for other from the overall memory allocated to Tomcat.
Regards Ganesh
回答1:
The memory is defined per JVM instance, so if you are using one tomcat you cannot do it.
However you can run two tomcat instances - one per web application - and then you will finer control on memory allocation for each webapp.
回答2:
No. There is no way for some portion of java code to control the consumption of memory by other portion of code called from first portion of code. In other words, the web container is just a java program which calls some other java class methods found in application.
So the only control one has is JVM arguments. And this arguments are only to hint the JVM where approximately to fail with out of memory error. No, it is not possible.
来源:https://stackoverflow.com/questions/1824099/tomcat-per-webapp-memory-settings