Skip to main content

cms gc

· One min read

背景

了解java 的cms gc 算法

路径

src\hotspot\share\gc\serial\defNewGeneration.cpp
// Ignores "ref" and calls allocate().
oop Generation::promote(oop obj, size_t obj_size) {
assert(obj_size == obj->size(), "bad obj_size passed in");

#ifndef PRODUCT
if (GenCollectedHeap::heap()->promotion_should_fail()) {
return NULL;
}
#endif // #ifndef PRODUCT

HeapWord* result = allocate(obj_size, false);
if (result != NULL) {
Copy::aligned_disjoint_words(cast_from_oop<HeapWord*>(obj), result, obj_size);
return cast_to_oop(result);
} else {
GenCollectedHeap* gch = GenCollectedHeap::heap();
return gch->handle_failed_promotion(this, obj, obj_size);
}
}

相关阅读