In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the example analysis of Tomcat running Java Web memory overflow, the article is very detailed, has a certain reference value, interested friends must read it!
If the program running in JVM, its memory heap and persistent storage area are full, and the program still wants to create an object instance, the garbage collector will start and try to free up enough memory to create the object. At this point, if the garbage collector does not have the ability to release enough memory, it will throw an OutOfMemoryError memory overflow error.
Memory management of SUN JVM:
SUN's JVM is similar to the human family, that is, creating an object in one place, giving it a chance to die many times before it takes up space for a long time, SUN JVM will be divided into:
1. Younger generation (Young generation), including EDEN and 2 survivor spaces (departure and destination the From space and the To space)
two。 Older Generation (Old generation)
3. * generation (Permanent generation)
The runtime datazones for Java virtual machines are generally classified as follows (not necessarily physical partitions):
1. Heap: mainly stores object instances, thread sharing
two。 Stack: mainly stores the method call state of a specific thread, which is exclusive to the thread
3. Local method stack: stores the calling state of local methods, exclusive by threads
4. PC registers: anyone who has taken an operating system course knows that threads are exclusive.
5. Method area: mainly stores type information, thread sharing
Therefore, when a memory overflow error is thrown, the type of memory leak is generally prompted, and it is generally divided by region:
1. Heap (heap) memory leak java.lang.OutOfMemoryError: Javaheap space: everyone is familiar with it. You can solve it by setting-Xms2048m-Xmx4096m.
two。 Stack memory leak: too much information such as intermediate variables maintained during the running of the current thread, such as stack over flow caused by common dead loops
3. Method permanent heap memory leak, that is, java.lang.OutOfMemoryError: PermGen space: the cause of occurrence is directly related to type loading and type unloading, which can be solved by setting-XX:MaxNewSize=256m-XX:MaxPermSize=256m.
In general, when the server memory is too small and provides a large number of access services, too many data objects may be cached to cause heap memory overflow. When the web application continues to expand and the loaded lib library reaches a certain size (4m), it is easy to report PermGen OOM, that is, method area overflow.
Write parameters to the environment variable in the Linux server:
Export CATALINA_OPTS= "- Xms2048m-Xmx4096m" export JAVA_OPTS= "- XX:MaxNewSize=256m-XX:MaxPermSize=256m"
Xmx * do not exceed 80% of the server's physical memory
The above is all the contents of the article "example Analysis of Tomcat running Java Web memory overflow". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.