在分析日志的过程中经常需要追踪GC是否异常及GC的相关信息,
可以在art/runtime/gc/heap.cc文件中添加打印日志的代码:
collector::GcType Heap::CollectGarbageInternal(collector::GcType gc_type, GcCause gc_cause,
bool clear_soft_references) {
Thread* self = Thread::Current();
// 打印GC日志
{
ReaderMutexLock mu(self, *Locks::mutator_lock_);
self->Dump(LOG(WARNING) <<"GC debug");
}
网友评论