Java object escapes, the object is allocated on the stack

Through the following two articles, we can draw some interesting conclusions: 

What is java escape analysis- Programming Language- Yisu Cloud

Java object escape and escape analysis_java escape analysis_Learning is sharing blog-CSDN blog

In the Java virtual machine, objects are allocated memory in the Java heap, which is a common knowledge. However, there is a special case, that is, if it is found through escape analysis that an object does not have an escape method, it may be optimized to allocation on the stack. This eliminates the need to allocate memory on the heap and garbage collection. This is also the most common off-heap storage technology. 

Guess you like

Origin blog.csdn.net/puzi0315/article/details/129643040