English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

The difference between JVM heap and stack

Stack memory:

  • The program runs in stack memory
  • The stack stores basic data types and references to objects in the heap
  • The stack is a runtime unit
  • The stack solves the running problem of the program, that is, how the program is executed, or how to process data 
  • One thread has an independent thread stack

Heap memory: 

  • Most of the data required for program execution is stored in stack memory
  • Objects are stored in the heap
  • The heap is a storage unit, and the heap is just a shared memory block
  • The heap solves the problem of data storage, that is, how to store data and where to store it
  • All threads share heap memory

Parameter passing in Java (is it passing by value or by reference?):

  • Program execution always occurs in the stack, so there is only the issue of passing basic types and object references when passing parameters, and the object itself is not passed directly

That's all for this article. I hope the content of this article can bring some help to everyone's learning or work, and I also hope to support the Yelling Tutorial more!

Declaration: The content of this article is from the Internet, and the copyright belongs to the original author. The content is contributed and uploaded by Internet users spontaneously. This website does not own the copyright, has not been manually edited, and does not assume any relevant legal liability. If you find any content suspected of copyright infringement, please send an email to notice#w3Please send an email to codebox.com (replace # with @ when sending an email) to report any violations, and provide relevant evidence. Once verified, this site will immediately delete the infringing content.

You May Also Like