In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article "JVM heap memory overflow, other threads can continue to work?" most people do not understand, so the editor summarizes the following content, detailed, clear steps, with a certain reference value, I hope you can get something after reading this article, let's take a look at this "JVM heap memory overflow, other threads can continue to work" article bar.
To talk about the answer first, the answer is that it still works.
The code is as follows:
Public class JvmThread {
Public static void main (String [] args) {
New Thread (()-> {
List list = new ArrayList ()
While (true) {
System.out.println (new Date () .toString () + Thread.currentThread () + "= =")
Byte [] b = new byte [1024 * 1024 * 1]
List.add (b)
Try {
Thread.sleep (1000)
} catch (Exception e) {
E.printStackTrace ()
}
}
}) .start ()
/ / Thread two
New Thread (()-> {
While (true) {
System.out.println (new Date () .toString () + Thread.currentThread () + "= =")
Try {
Thread.sleep (1000)
} catch (Exception e) {
E.printStackTrace ()
}
}
}) .start ()
}
}
The results show:
Wed Nov 07 14:42:18 CST 2018 Thread [Thread-1 record5 main] =
Wed Nov 07 14:42:18 CST 2018 Thread [Thread-0pence5 main] =
Wed Nov 07 14:42:19 CST 2018 Thread [Thread-1 record5 main] =
Wed Nov 07 14:42:19 CST 2018 Thread [Thread-0pence5 main] =
Exception in thread "Thread-0" java.lang.OutOfMemoryError: Java heap space
At com.gosaint.util.JvmThread.lambda$main$0 (JvmThread.java:21)
At com.gosaint.util.JvmThread$$Lambda$1/521645586.run (Unknown Source)
At java.lang.Thread.run (Thread.java:748)
Wed Nov 07 14:42:20 CST 2018 Thread [Thread-1 record5 main] =
Wed Nov 07 14:42:21 CST 2018 Thread [Thread-1 record5 main] =
Wed Nov 07 14:42:22 CST 2018 Thread [Thread-1 record5 main] =
JVM startup parameter settings:
The figure above shows the changes in the JVM heap space. If we take a closer look at the changes in the curve between 14-42-14-42-25, you will find that the number of heaps used has suddenly dropped sharply! This means that when a thread throws an OOM exception, all the memory resources it occupies are freed so that it does not affect the running of other threads!
The above is about the content of this article on "can other threads continue to work after JVM heap memory overflow?" I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please 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.