JDK 8 Memory Layout and garbage collection

2019-01-31 19:01发布

From what I know, starting with JDK 8 the PermGen will be a page in java's history. Everything nice and merry... but what will the new Memory Layout look like? Will this affect GC on the new platform?

2条回答
ゆ 、 Hurt°
2楼-- · 2019-01-31 19:33

This is when permGen is there enter image description here

After Metaspace is introduced enter image description here

Definitely, there is lot of improvement in GC in Java 8. You can check this stackoverflow post

In Metaspace, multiple mapped virtual memory spaces are allocated for metadata and allocation ( in chunks) is per class loader depending on the type of classloader and its liveness . Chunks are returned to free chunks list and also virtual memory spaces returned when emptied.

Advantage of GC would be

  • During full collection, metadata to metadata pointers are not scanned
  • A lot of complex code (particularly for CMS) for metadata scanning was removed.
  • Metaspace contains few pointers into the Java heap.
  • No compaction costs for metadata
  • Reduces root scanning (no scanning of VM dictionary of loaded classes and other internal hashtables).

More detail is here

查看更多
SAY GOODBYE
3楼-- · 2019-01-31 19:38

PermGen is replaced with Metaspace in Oracle/Sun JDK8, which is very similar. The main difference is that Metaspace can expand at runtime.

查看更多
登录 后发表回答