当前位置:网站首页>Hotspot Metaspace
Hotspot Metaspace
2022-06-12 09:16:00 【symop】
The new project encountered Metaspace Lack of space leads to fullgc, So I want to find out Metaspace Initial size , When is the expansion , How much capacity to expand …
First, let's explain GC In the log ,Metaspace In this line used ,capacity ,committed ,reserved What exactly does it mean ? also class space In this line used ,capacity ,committed ,reserved What exactly does it mean ?
Metaspace used 13009K, capacity 13344K, committed 13568K, reserved 1060864K
class space used 1584K, capacity 1690K, committed 1792K, reserved 1048576K

The picture above is Metaspace.hpp In the source , I just cut a picture , This is just an expression Metaspace Which components are not explained for the parameters in the log , So I searched the official website , about Metaspace The parameters in this line are explained as follows .
The above is from from
used: The amount of space in the loaded class .
capacity: The space of the metadata of the currently allocated block .
committed: Number of space blocks .
reserved: yes jvm The size of memory reserved during startup according to parameters and operating system .
class space Yes for class The sum of memory .
Metaspace The initialization size code is as follows
void MetaspaceGC::initialize() {
// Set the high-water mark to MaxMetapaceSize during VM initializaton since
// we can't do a GC during initialization.
_capacity_until_GC = MaxMetaspaceSize;
}
MaxMetaspaceSize The field is defined in globals.hpp file , As for how to initialize, I can't follow , I am also a colored pen , It also means that I don't know the initialization size .
Every time the garbage collection is completed, it will call MetaspaceGC::compute_new_size, Realize dynamic adjustment Metaspace The function of size , The following is the source code. I only copy the code on how to expand the capacity .
void MetaspaceGC::compute_new_size() {
assert(_shrink_factor <= 100, "invalid shrink factor");
uint current_shrink_factor = _shrink_factor;
_shrink_factor = 0;
const size_t used_after_gc = MetaspaceAux::committed_bytes();
const size_t capacity_until_GC = MetaspaceGC::capacity_until_GC();
//MinMetaspaceFreeRatio yes GC To be guaranteed after completion Metaspace The lowest percentage of free space , Default yes 40%
const double minimum_free_percentage = MinMetaspaceFreeRatio / 100.0;
const double maximum_used_percentage = 1.0 - minimum_free_percentage;
const double min_tmp = used_after_gc / maximum_used_percentage;
size_t minimum_desired_capacity =
(size_t)MIN2(min_tmp, double(max_uintx));
// Don't shrink less than the initial generation size
minimum_desired_capacity = MAX2(minimum_desired_capacity,
MetaspaceSize);
if (PrintGCDetails && Verbose) {
gclog_or_tty->print_cr("\nMetaspaceGC::compute_new_size: ");
gclog_or_tty->print_cr(" "
" minimum_free_percentage: %6.2f"
" maximum_used_percentage: %6.2f",
minimum_free_percentage,
maximum_used_percentage);
gclog_or_tty->print_cr(" "
" used_after_gc : %6.1fKB",
used_after_gc / (double) K);
}
size_t shrink_bytes = 0;
// If the current capacity_until_GC Less than expected , Then expand the capacity
if (capacity_until_GC < minimum_desired_capacity) {
size_t expand_bytes = minimum_desired_capacity - capacity_until_GC;
//64 Bit system 8 Byte alignment
expand_bytes = align_size_up(expand_bytes, Metaspace::commit_alignment());
//MinMetaspaceExpansion Indicates the lowest expansion value during capacity expansion , The default is 256k, Below this value, no expansion is allowed
if (expand_bytes >= MinMetaspaceExpansion) {
size_t new_capacity_until_GC = 0;
bool succeeded = MetaspaceGC::inc_capacity_until_GC(expand_bytes, &new_capacity_until_GC);
assert(succeeded, "Should always succesfully increment HWM when at safepoint");
Metaspace::tracer()->report_gc_threshold(capacity_until_GC,
new_capacity_until_GC,
MetaspaceGCThresholdUpdater::ComputeNewSize);
if (PrintGCDetails && Verbose) {
gclog_or_tty->print_cr(" expanding:"
" minimum_desired_capacity: %6.1fKB"
" expand_bytes: %6.1fKB"
" MinMetaspaceExpansion: %6.1fKB"
" new metaspace HWM: %6.1fKB",
minimum_desired_capacity / (double) K,
expand_bytes / (double) K,
MinMetaspaceExpansion / (double) K,
new_capacity_until_GC / (double) K);
}
}
return;
}
......
}
used_after_gc and capacity_until_GC These two variables are familiar , Corresponding to the logs mentioned above Metaspace used and capacity, The rest of the important code has been commented .
边栏推荐
- Introduction to applet cloud development -- questionnaire evaluation applet practice (7)
- Chapter V -[bx] and loop instructions
- MySQL installation
- Quick sort
- consul 配置相关
- 90%以上软件公司都会问的软件测试面试题赶紧来背吧
- Résoudre le problème de demander à l'élément d'être ouvert lorsque l'unit é est ouverte et que vous n'avez pas été ouvert auparavant (peut - être fermé anormalement auparavant)
- Full alphabetic arrangement (pure alphabetic password dictionary)
- Basic exercise decomposing prime factors
- 帮助你拿到offer的金融测试面试题
猜你喜欢
软件测试基础知识分享,写点你不知道的

测试用例如何编写?
ADB command collection, let's learn together

Unittest test framework

Chapter 8 - two basic problems of data processing

Detailed explanation of iSCSI (V) -- actual operation of iSCSI client configuration

Jupyter notebook sets the default browser to open with an error syntaxerror: (Unicode error) 'UTF-8' codec can't decode byte 0xd4
![Sword finger offer:[day 8 dynamic planning (simple)] --- > frog jumping on steps](/img/0a/65bc44850e52204af278e50a8f86eb.jpg)
Sword finger offer:[day 8 dynamic planning (simple)] --- > frog jumping on steps
Selenium interview question sharing
Cas d'essai et spécification de description des bogues référence
随机推荐
ABC253F Operations on a Matrix
自动化测试框架的设计原则有哪些?我帮你总结好了快来看
Mycat的使用
Introduction Fibonacci series
mySql学习记录——二、mySql建表命令
Meeting time (topology sorting +dp)
L1-019 who goes first
软件测试报告中常见的疏漏,给自己提个醒
Distributed transaction solution 1: TCC (compensation transaction)
Complete knapsack problem 1
Countdownlatch example
Test case and bug description specification reference
Node sample background setup
Automated test learning path, come and learn
90%以上软件公司都会问的软件测试面试题赶紧来背吧
Microservice gateway
自动化测试学习路线,快来学吧
(十五) TweenRunner
Unittest测试框架
128. 最长连续序列-哈希表