Java Execution Process

Here attached an article about heap (堆) and stack (栈).
HeapAndStack
Java will store all things into system memory (system memory is physical mem + virtual mem), then it’s the OS to decide they go to physical memory or hard disk (virtual memory) later.

堆是先进先出,而栈是先进后出. But in Java, not that obvious differences.
Classically, the stuff in stack, OS can release automatically; but in heap, you have to release it manually. But Java has garbage collection, so the difference is not obvious now.

Two samples:

原文地址:https://www.cnblogs.com/backpacker/p/2269964.html