hotspot/src/share/vm/services/memoryService.cpp
// Add memory pool(s) for one generation
void MemoryService::add_generation_memory_pool(Generation* gen,
MemoryManager* major_mgr,
MemoryManager* minor_mgr) {
{- -------------------------------------------
(1) 以下で, New/Old 領域用の MemoryPool を取得する.
使用している GC アルゴリズムに応じて, 以下のように適切な関数が呼び出される.
* Eden 領域用の MemoryPool
MemoryService::add_space()
(DefNew の場合も ParNew の場合も呼び出す関数は同じ)
* Survivor 領域用の MemoryPool
MemoryService::add_survivor_spaces()
(DefNew の場合も ParNew の場合も呼び出す関数は同じ)
* Old 領域用の MemoryPool
* MSC の場合
MemoryService::add_gen()
* CMS の場合
MemoryService::add_cms_space()
---------------------------------------- -}
Generation::Name kind = gen->kind();
int index = _pools_list->length();
switch (kind) {
case Generation::DefNew: {
assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers");
DefNewGeneration* young_gen = (DefNewGeneration*) gen;
// Add a memory pool for each space and young gen doesn't
// support low memory detection as it is expected to get filled up.
MemoryPool* eden = add_space(young_gen->eden(),
"Eden Space",
true, /* is_heap */
young_gen->max_eden_size(),
false /* support_usage_threshold */);
MemoryPool* survivor = add_survivor_spaces(young_gen,
"Survivor Space",
true, /* is_heap */
young_gen->max_survivor_size(),
false /* support_usage_threshold */);
break;
}
#ifndef SERIALGC
case Generation::ParNew:
case Generation::ASParNew:
{
assert(major_mgr != NULL && minor_mgr != NULL, "Should have two managers");
// Add a memory pool for each space and young gen doesn't
// support low memory detection as it is expected to get filled up.
ParNewGeneration* parnew_gen = (ParNewGeneration*) gen;
MemoryPool* eden = add_space(parnew_gen->eden(),
"Par Eden Space",
true /* is_heap */,
parnew_gen->max_eden_size(),
false /* support_usage_threshold */);
MemoryPool* survivor = add_survivor_spaces(parnew_gen,
"Par Survivor Space",
true, /* is_heap */
parnew_gen->max_survivor_size(),
false /* support_usage_threshold */);
break;
}
#endif // SERIALGC
case Generation::MarkSweepCompact: {
assert(major_mgr != NULL && minor_mgr == NULL, "Should have only one manager");
add_gen(gen,
"Tenured Gen",
true, /* is_heap */
true /* support_usage_threshold */);
break;
}
#ifndef SERIALGC
case Generation::ConcurrentMarkSweep:
case Generation::ASConcurrentMarkSweep:
{
assert(major_mgr != NULL && minor_mgr == NULL, "Should have only one manager");
ConcurrentMarkSweepGeneration* cms = (ConcurrentMarkSweepGeneration*) gen;
MemoryPool* pool = add_cms_space(cms->cmsSpace(),
"CMS Old Gen",
true, /* is_heap */
cms->reserved().byte_size(),
true /* support_usage_threshold */);
break;
}
#endif // SERIALGC
default:
assert(false, "should not reach here");
// no memory pool added for others
break;
}
assert(major_mgr != NULL, "Should have at least one manager");
// Link managers and the memory pools together
for (int i = index; i < _pools_list->length(); i++) {
MemoryPool* pool = _pools_list->at(i);
major_mgr->add_pool(pool);
if (minor_mgr != NULL) {
minor_mgr->add_pool(pool);
}
}
}
This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.