stack-allocation

When can Hotspot allocate objects on the stack? [duplicate]

只愿长相守 提交于 2019-12-17 10:34:41
问题 This question already has answers here : Eligibility for escape analysis / stack allocation with Java 7 (3 answers) Closed 2 years ago . Since somewhere around Java 6, the Hotspot JVM can do escape analysis and allocate non-escaping objects on the stack instead of on the garbage collected heap. This results in a speedup of the generated code and reduces pressure on the garbage collector. What are the rules for when Hotspot is able to stack allocate objects? In other words when can I rely on

When can Hotspot allocate objects on the stack? [duplicate]

假如想象 提交于 2019-11-28 06:03:05
This question already has an answer here: Eligibility for escape analysis / stack allocation with Java 7 3 answers Since somewhere around Java 6, the Hotspot JVM can do escape analysis and allocate non-escaping objects on the stack instead of on the garbage collected heap. This results in a speedup of the generated code and reduces pressure on the garbage collector. What are the rules for when Hotspot is able to stack allocate objects? In other words when can I rely on it to do stack allocation? edit : This question is a duplicate, but (IMO) the answer below is a better answer than what is