内存分配和变量的生命

我的问题或更确切的问题如下:

1)静态变量驻留在哪里。 有些文章称它们位于堆上,有些人在perm gen区域中使用类定义,因为它们是类属性。 我理解第二个选项可能是正确的,因为它是一个类属性。
2)如果最终变量驻留在哪里以及它的生命是什么:a)它是一个类型为primitive的实例变量b)它是一个类型为primitive的方法的局部变量c)它是一个类型为reference的实例变量b)它是一个本地变量类型引用方法的变量
3)如果参考局部变量是本地变量,它们在哪里存储。
4)在数组的情况下,内存分配存在任何差异,因为它们是实例变量或本地线程变量。

谢谢

Where does the static variable reside

静态变量驻留在Method Area ,而permgen位于方法区域内。

 Where does the final variable reside and what is its life if Its an instance variable of type primitive 

如果它的实例变量,它会停留在它所属Heap inside the ObjectHeap inside the Object ,并且不在范围内,因为没有对包含它的Object的引用。

Its a local variable of a method of type primitive

它停留在堆栈上,并且超出了范围,因为达到了大括号的方法…

Its an instance variable of type reference

它停留在它所属Heap inside the Object ,并且超出范围,因为没有对包含它的对象的引用。

Its a local variable of a method of type reference

它停留在堆栈上,并且超出了范围,因为达到了大括号的方法…

Where are the reference local variables stored if they are local.

在堆栈上……

In case of arrays is there any difference in memory allocation as in they are instance variable or local thread variable.

好吧, Array是一个对象,它存储在Heap ….但是从Java 6u23版本开始,已经引入了Escape Analysis ,根据这个,如果JVM决定Object不能逃避Method,它会尝试创建线程堆栈上的对象,而不是HEAP HEAP ….