Heap Memory Pool:
A. Eden Space(heap):大多数物件初始化时从Eden Space池分配记忆体,即是存在于此池中
B. Survivor Space(heap):此池包含的物件是那些原先在eden space中,但是已经经历过垃圾回收而仍然存在的物件。
C. Tenured Generation(heap):在surviver space中已经存在了一段时间之后的物件会移动到这个池中。
Non-Heap Memory Pool:
D. Code Cache (non-heap):储存编译的程式码和local variables。
E. Permanent Generation(non-heap):包含虚拟机器自身的所有反射资料。 比如class和mothod物件。 对于使用class data sharing的JVM,分为唯读(shared-ro)和读写(shared-rw)两个区域。
Yes it can. There is often the misconception that string constants cannot be garbage collected. However the only requirement that the JVM specification stipulates is that identity comparison works for constant string values. There is no requirement that the constant be the same object throughout the lifetime of the JVM. Hence if there are no references left to a string constant, there is no reason why it cannot be garbage collected.
To prove this take the following code:
public class PermGenDemo { public static void main(String[] args) { int i = 0; while (true) { ("string-" + ++i).intern(); } }}
If the above code is run using the following command:
$ java -verbose:gc -XX:PermSize=8m -XX:MaxPermSize=64m PermGenDemo
The following output will be seen (note output cut for brevity):
[Full GC [PSYoungGen: 32K->0K(28928K)] . . . [PSPermGen: 65535K->6461K(65536K)]][Full GC [PSYoungGen: 32K->0K(31168K)] . . . [PSPermGen: 65535K->6461K(65536K)]]
联系客服