java中堆栈内存
Sometime back I wrote a couple of posts about Java Garbage Collection and Java is Pass by Value. After that I got a lot of emails to explain about Java Heap Space, Java Stack Memory, Memory Allocation in Java and what are the differences between them.
有时我写了几篇有关Java垃圾收集的文章, Java是“按价值传递” 。 之后,我收到了很多电子邮件,以解释Java堆空间 , Java堆栈内存 , Java中的内存分配以及它们之间的区别。
You will see a lot of reference to Heap and Stack memory in Java, Java EE books and tutorials but hardly complete explanation of what is heap and stack memory in terms of a program.
您将在Java,Java EE书籍和教程中看到很多有关堆和堆栈内存的参考,但是几乎没有就程序而言完全解释堆和堆栈内存。
Java堆空间 (Java Heap Space)
Java Heap space is used by java runtime to allocate memory to Objects and JRE classes. Whenever we create an object, it’s always created in the Heap space.
Java运行时使用Java堆空间为Objects和JRE类分配内存。 每当我们创建对象时,它总是在堆空间中创建。
Garbage Collection runs on the heap memory to free the memory used by objects that don’t have any reference. Any object created in the heap space has global access and can be referenced from anywhere of the application.
垃圾回收在堆内存上运行以释放没有任何引用的对象使用的内存。 在堆空间中创建的任何对象都具有全局访问权限,并且可以从应用程序的