JVM stack overflow simulation

Heap memory overflow:

1) First set about the heap memory size, I'm here to 2M

2) look at the code:

public class HeapOverflow {
    static List<Person> list = new ArrayList<>();

    public  static  void main (String [] args) throws Exception {
         the while ( to true ) {
 //           the Person Person = Person.getInstance (); This is a single example of a single embodiment will not have memory overflow, because the JVM heap memory the same subject is always only one memory address, that will only allocate memory once 
            the Person the Person = new new the Person ();
            list.add(person);
            Thread.sleep(1);
        }
    }

}

 

operation result:

2, stack overflow Memory: recursive Here, when the main thread came in the Java virtual machine will open a virtual machine station

Guess you like

Origin www.cnblogs.com/sunxuesong/p/12036022.html