In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces OutOfMemoryError to you how to create a new native thread, the content is very detailed, interested friends can refer to, I hope to help you.
You may need to adjust both the operating system and tomcat jvm parameters to achieve this goal.
This phenomenon is rare and strange, mainly related to the proportion of jvm and system memory.
This is odd because the JVM has been allocated a large amount of memory (say 1.5 gigabytes) by the system, and it takes up at least half of the available memory. It has been found that with a large number of threads, the more memory you allocate to the JVM, the more likely this error is to occur.
Each 32-bit process can use up to 2 gigabytes of available memory, since the other 2 gigabytes are reserved by the operating system. Assuming 1.5G is used for JVM, 500M of available memory remains. Part of this 500 MB memory must be used to load the system dll, so the real rest may only be 400 MB, and now the key point appears: when you create a thread in Java, you will also create a Thread object in JVM memory, but at the same time you will create a real physical thread in the operating system (see JVM specification), and the operating system will create this physical thread in the remaining 400 MB memory, not in the JVM's 1500 MB memory heap. In jdk 1.4, the default stack size was 256KB, but in jdk 1.5, the default stack size was 1 MB per thread, so we could only create up to 400 available threads out of the remaining 400 MB of available memory.
The conclusion is that to create more threads, you must reduce the maximum memory allocated to the JVM. Another option is to host the JVM in your JNI code.
Give an estimate of the maximum number of threads that can be created:
(MaxProcessMemory - JVMMemory - ReservedOsMemory) / (ThreadStackSize) = Number of threads
For jdk 1.5, assume the operating system reserves 120 MB of memory:
1.5GB JVM: (2GB-1.5Gb-120MB)/(1MB) = ~380 threads
1.0GB JVM: (2GB-1.0Gb-120MB)/(1MB) = ~880 threads
In 2000/XP/2003 boot.ini there is a boot option, such as: /PAE /3G, which allows the user process to expand the maximum memory to 3G, then the operating system can only occupy up to 1G of virtual memory. That should allow the JVM to create more threads.
Therefore, this situation needs to be adjusted in conjunction with the operating system.
Therefore, we need to diagnose tomcat memory allocation differently in different situations to solve the problem fundamentally
OutOfMemoryError about how to create a new native thread to share here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.
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.