课程: Java Memory Management: Values and References

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Stack memory

Stack memory

- [Narrator] The stack memory is the memory that's used for executing methods. Inside the method, primitives and objects exist. The values of the primitives are stored directly in the stack. The objects are not stored on the stack. Instead the object reference is stored. The object reference is the address of where to find the object on the heap. Stack memory makes different blocks of memory for every method. Once the method is done, the block gets removed. And the block of method memory that was laying underneath it, the method that's called the other method can be accessed again. When the method is not done, it calls another method, new block is being stored on top of this method memory block with the primitive and references for the memory inside there. So let's have a look at a visualization of this. So, here's the stack memory. And inside the stack memory we have method 1, and method 1 has a bunch of values and references, and they're stored inside this memory block for this…

内容