Skip to main content
PreparationZone Logo
PreparationZone
Back to Java

Java · Hard · Pro

Escape analysis and scalar replacement — stack allocation?

JavaMemory & JVMArchitect
Model answerPreview

Escape analysis

The JIT analyzes whether an object escapes a method/thread. Non-escaping objects may be scalar replaced (fields stored as locals) or stack-allocated—eliminating heap allocation in…