The difference between JVM heap and stack

  • 2020-06-12 08:55:41
  • OfStack

Stack memory:

The program runs in stack memory What's stored on the stack are the basic data types and references to objects in the heap The stack is the unit of runtime
The stack solves the running problem of the program, how does the program execute, or how does it handle the data 1 thread 1 independent thread stack

Heap memory:

Most of the data needed to run the program is stored in stack memory Objects are stored in the heap The heap is the unit of storage, and the heap is just one block of Shared memory The heap solves the data storage problem, which is how and where to put the data
All threads share heap memory

Parameter passing in Java (what about passing values? Or is it a quote? ) :

The program is always run on the stack, so parameter passing is only a matter of passing the basic type and object reference, not the object itself

Related articles: