Tomcat 每个 webapp 内存设置
我有两个 web 应用程序在 tomcat 中运行。 Java 堆空间是为 Tomcat 分配的,并且由两个应用程序共享。其中一个应用程序消耗更多内存,而其他应用程序则耗尽内存。
有没有办法为每个 Web 应用程序设置内存设置。假设一个 Web 应用程序占分配给 Tomcat 的总内存的 70%,其他应用程序占 30%。
问候 加内什
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
内存是按 JVM 实例定义的,因此如果您使用一个 tomcat,则无法执行此操作。
不过,您可以运行两个 tomcat 实例(每个 Web 应用程序一个),然后您可以更好地控制每个 Web 应用程序的内存分配。
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.
不可以。Java 代码的某些部分无法控制从代码的第一部分调用的其他代码部分对内存的消耗。换句话说,Web 容器只是一个 Java 程序,它调用应用程序中的其他一些 Java 类方法。
所以唯一的控制权就是 JVM 参数。这个参数只是为了暗示 JVM 大约会在哪里因内存不足错误而失败。不,这是不可能的。
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.