Where does the Static members reside in memory,is it permanent generation?

254 Views Asked by At

Static members where does they reside. i need an detail explanation of static ,local and instance members memory allocation(variables,methods). Memory management(Is it permanent generation).

2

There are 2 best solutions below

1
On BEST ANSWER

static members : permanent generation(heap)

local variable : stack memory which is not heap. refer here http://tutorials.jenkov.com/java-concurrency/java-memory-model.html

0
On

It depends on the Java version you are using:

  1. Pre Java8: statics (just like other "permanent" things) were stored in a PermGen. It's simply part of the memory model like young gen and old gen.
  2. Java8: here PermGen got removed! For a number of reasons, for instance it was hard to tune it. Of course all the data didn't just got abandoned, since we still need it. It was just moved to Metaspace, which resides inside native memory (so outside Java heap).