staticchar* DoGetHeapProfileLocked(char* buf, int buflen){ // We used to be smarter about estimating the required memory and // then capping it to 1MB and generating the profile into that. if (buf == NULL || buflen < 1) returnNULL;
RAW_DCHECK(heap_lock.IsHeld(), ""); int bytes_written = 0; if (is_on) { HeapProfileTable::Stats const stats = heap_profile->total(); (void)stats; // avoid an unused-variable warning in non-debug mode. bytes_written = heap_profile->FillOrderedProfile(buf, buflen - 1); // FillOrderedProfile should not reduce the set of active mmap-ed regions, // hence MemoryRegionMap will let us remove everything we've added above: RAW_DCHECK(stats.Equivalent(heap_profile->total()), ""); // if this fails, we somehow removed by FillOrderedProfile // more than we have added. } buf[bytes_written] = '\0'; RAW_DCHECK(bytes_written == strlen(buf), "");