当前位置:网站首页>If a thread overflows heap memory or stack memory, will other threads continue to work

If a thread overflows heap memory or stack memory, will other threads continue to work

2022-06-25 15:19:00 xiao326791055

If a thread has a heap memory overflow , Or stack memory overflow , Whether other threads will continue to work

Don't bullshit , Basic information of synchronization status and identification hash code , Whether it's a heap memory overflow , Or stack memory overflow , The rest of the threads will continue to work

1: First, test the heap memory overflow

	**1.1: The trial IDEA test , The code is as follows :**

 Insert picture description here

	**1.2: Then set the running memory size **

 Insert picture description here

	1.3: Appoint main Method , And open jvisualvm
	
	jvisualvm The position of is JDK Of bin In the folder 

 Insert picture description here

 View the running of the code jvisualvm Monitoring the page 

 Insert picture description here

You can see in the 10 spot 25 branch 33 Once per second GC, At this point, let's look at our output records , Whether there is a memory overflow

 Insert picture description here

And after a heap memory overflow , Other threads are still executing .

2: Stack memory overflow is the same as heap memory overflow , Other threads will still execute

2.1: The stack memory code is as follows 

 Insert picture description here

2.2: give the result as follows :

 Insert picture description here

 After thread memory overflow , The memory occupied by threads will be released quickly , It will not affect the running of other threads .
原网站

版权声明
本文为[xiao326791055]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202200504232618.html