Confidentiality

multiple webapps running on the same cat using the same jvm. someday one webapp that has a memory leak will crash all jvm and impact other web applications. any recommendation how to isolate that without having to use multiple jvm and tomcat

+4
source share
7 answers

Within a single JVM, everything shares the same memory. There is no system for allocating individual pools or quotas.

If one of your applications behaves very badly in this regard, the only thing you can do is isolate it in a separate JVM (separate Tomcat).

+6
source

Are applications executable as separate processes? Or the same one?

You should look at the profiling first to find a memory leak https://stackoverflow.com/questions/1716597/java-memory-leak-detection-tools .

However, as a quick solution from the inside out, you can use Runtime.getRuntime (). totalMemory () to find out how much memory is being used and if it grows above a certain limit and you know which application is causing the problem, you can restart this application.

You can also try running System.gc (), which is a terrible way to do this, and really should not be used, as the JVM can ignore it.

+1
source

As far as I know, the short answer is: No, this is not possible. Tomcat uses a single memory space for all running applications.

My answer from the knee joint is that you should fix the memory leak, and not try to isolate the wrong application. Treatment is better than quarantine. For some reason, I don’t know the details of your problem, maybe for some reason this is not practical.

+1
source

You cannot isolate applications in one JVM (although you can do things like a tool for certain ClassLoader diagnostic applications)

If your problem is administration / configuration (rather than shared memory), you can run multiple instances of Tomcat from the same installation using the .home and catalina.base

+1
source

JSR 121 was developed to address this issue, but it has not yet been implemented.

+1
source

There is no standard system in Java for truly isolating the memory used by web applications.

However, you can write some byte encoding of the byte code to keep track of how much memory is allocated by a particular application. If it crosses a certain threshold, you can throw an exception and stop the application from allocating more memory. What do you want to do if you can track all the memory consumed by the web application? What are you trying to implement?

Please note that this will only work effectively to find out how much memory is allocated to the web folder, and not how much it currently consumes on the system. To get this metric, you will need the bytecode weave finalize () for all objects. Since finalize () is launched using the JVM with maximum efficiency, this may not give you the most accurate value if the system is under load. The JVM will strip these finalized topics, and your value will never be updated, even if the objects have been cleared.

0
source

To upgrade this version, you can now run multiple applications on the same JVM. Applications run in isolated virtual Java containers that protect your applications from noisy neighbors and also allow you to share resources in your applications. This gives you isolation, resilience, and increased density for Apache Tomcat. Download it from www.elasticat.com NB. I work for Waratek who developed this new JVM

0
source

Source: https://habr.com/ru/post/1304538/


All Articles