Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method of modifying and monitoring the amount of JVM memory occupied by Tomcat?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

What is the method of modifying and monitoring the amount of JVM memory occupied by Tomcat? I believe many inexperienced people are at a loss about it. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

At the beginning of Tomcat design, taking into account the different performance of customers' servers to prevent virtual memory from running out, the default setting of Tomcat, JVM, allows the use of a minimum of 64m memory. However, in some projects that take up a lot of resources or high concurrency, it is easy to cause insufficient memory and Tomcat will stop automatically without any sign.

Modification method and Monitoring method of JVM memory occupied by Tomcat

Tomcat itself is a good server container, free and powerful, which is silently supported by many powerful companies and organizations, creating a position that can compete with charging containers such as weblogic, but Tomcat itself still has some defects.

At the beginning of Tomcat design, taking into account the different performance of customers' servers to prevent virtual memory from running out, the default setting of Tomcat, JVM, allows the use of a minimum of 64m memory. However, in some projects that take up a lot of resources or high concurrency, it is easy to cause insufficient memory and Tomcat will stop automatically without any sign.

* the solution is to modify Tomcat's restrictions on JVM memory usage.

There are two methods:

1. Edit the catalina.bat file under% CATALINA_HOME%\ bin

Write in front of the top line

SetJAVA_OPTS=-Xms512m-Xmx1024m

Where-Xms represents the minimum number of JVM memory, and-Xmx represents the number of * * memory.

For example, I have set it to a minimum of 512 and 1024.

Of course, this minimum * * does not mean that you can only use 1024. In fact, this setting is set for the system, because the amount of memory occupied by this JVM is actually for virtual memory. This setting means that no matter how much virtual memory is occupied by the system, you have to ensure that a minimum of 512m of virtual memory is shared by JVM. Of course, no matter how large my JVM is, it will not exceed 1024 to threaten the memory use of the system.

2, add the following two values to the environment variable

Add two attributes of Tomcat_OPTS,CATALINA_OPTS, such as SETCATALINA_OPTS=-Xms512m-Xmx1024m;, which means the same as above.

But how do you see how much JVM memory is used? The easiest way is to open the task manager-> process-> View-> Select the column, select the number of virtual memory-> OK, you will see the number of virtual memory, at this time, you will see that the virtual memory has 512mm 1024m of space occupied, then it is occupied by the value you set, JVM memory use, will be used in this occupied range.

Another way is to write a small script named ram.jsp

The code is

After reading the above, have you mastered the method of modifying and monitoring the amount of JVM memory occupied by Tomcat? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report