PermGen and Metaspace

4 篇文章 0 订阅

原文地址
In this post, we take a look at Metaspace, and explain how to increase the performance of your JVM with a few simple commands.

PermGen is an abbreviation for Permanent Generation and it’s a special heap space which is separate from the main Java heap where JVM keeps track of metadata of the classes which have been loaded. In Java 8, PermGen has been renamed to Metaspace - with some subtle differences. From our perspective, it is important to note that Metaspace has an unlimited default maximum size. On the contrary, PermGen from Java 7 and earlier has a default maximum size of 64 MB on 32-bit JVM and 82 MB on the 64-bit version. Of course, these are not the same as the initial sizes. Java 7 and earlier starts with something around 12-21 MB of the initial PermGen space.

JVM

Default maximum PermGen size (MB)

Default maximum Metaspace size

32-bit client JVM

64

unlimited

32-bit server JVM

64

unlimited

64-bit JVM

82

unlimited

It is worthwhile to mention that prior to Java 7, interned Strings used to be kept on the PermGen. That caused some serious problems with the infamous:

java.lang.OutOfMemoryError: PermGen space

Whenever there is a need to resize PermGen/Metaspace, JVM will do it as it does with the standard heap. Resizing those spaces requires a full GC, which is always an expensive operation. It can usually be observed during a startup when a lot of classes are being loaded. Especially if the application has dependencies on many external libraries. If there are a lot of full GCs during the startup, it’s usually because of that. If that case, increasing the initial size can boost the startup performance.

To increase PermGen, we have the following commands:

-XX:PermSize=N - sets the initial (and minimum size) of the Permanent Generation space.

-XX:MaxPermSize=N - sets the maximum size of the Permanent Generation space.

In Java 8 and onwards, we can set the initial and maximum size of Metaspace using the following commands:

-XX:MetaspaceSize=N - sets the initial (and minimum size) of the Metaspace.

-XX:MaxMetaspaceSize=N - sets the maximum size of the Metaspace.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值