Что такое 'PermSize' в Java?

Немного отличающееся использование должно ускорить отражение; т.е. вместо того, чтобы использовать отражение каждый раз, можно использовать Delegate.CreateDelegate для создания (введенного) делегата в методе (MethodInfo), и вызов тот делегат вместо этого. Это тогда очень более быстро на вызов, поскольку проверки были уже сделаны.

С Expression, можно также сделать то же для создания кода на лету - например, можно легко создать Expression, который представляет + оператор для типа, выбранного во времени выполнения (для оказания поддержки оператора для дженериков, которые язык не обеспечивает); и можно скомпилировать Expression во введенного делегата - сделанное задание.

65
задан Chase 27 September 2012 в 22:20
поделиться

3 ответа

A quick definition of the "permanent generation":

"The permanent generation is used to hold reflective data of the VM itself such as class objects and method objects. These reflective objects are allocated directly into the permanent generation, and it is sized независимо от другого generations." [ref]

In other words, this is where class definitions go (and this explains why you may get the message OutOfMemoryError: PermGen space if an application loads a large number of classes and/or on redeployment).

Note that PermSize is additional to the -Xmx value set by the user on the JVM options. But MaxPermSize allows for the JVM to be able to grow the PermSize to the amount specified. Initially when the VM is loaded, the MaxPermSize will still be the default value (32mb for -client and 64mb for -server) but will not actually take up that amount until it is needed. On the other hand, if you were to set BOTH PermSize and MaxPermSize to 256mb, you would notice that the overall heap has increased by 256mb additional to the -Xmx setting.

107
ответ дан 24 November 2019 в 15:21
поделиться

Постоянный пул содержит все, что не является данными вашего приложения, а скорее вещи, необходимые для виртуальной машины: обычно он содержит интернированные строки, байтовый код определенных классов,

9
ответ дан 24 November 2019 в 15:21
поделиться

This blog post gives a nice explanation and some background. Basically, the "permanent generation" (whose size is given by PermSize) is used to store things that the JVM has to allocate space for, but which will not (normally) be garbage-collected (hence "permanent") (+). That means for example loaded classes and static fields.

There is also a FAQ on garbage collection directly from Sun, which answers some questions about the permanent generation. Finally, here's a blog post with a lot of technical detail.

(+) Actually parts of the permanent generation will be GCed, e.g. class objects will be removed when a class is unloaded. But that was uncommon when the permanent generation was introduced into the JVM, hence the name.

23
ответ дан 24 November 2019 в 15:21
поделиться
Другие вопросы по тегам:

Похожие вопросы: