1 Usage 2 ----- 3 4 These scripts are made to parse TCMalloc output in order to extract certain 5 info from them. 6 7 In particular, these scripts rely on the error logging system for ChromeOS in 8 order to extract information. In order to use a script (e.g. total_mem.py), you 9 just have the command: 10 11 ./total_mem.py FILENAME 12 13 where FILENAME is the name of the log file to be parsed. 14 15 Codebase Changes 16 ---------------- 17 18 There are two ideas that motivate these changes: 19 20 1- Turn on TCMalloc sampling. 21 2- Use perf to collect the sample information. 22 23 The following files have to be changed: 24 25 in chrome/browser/metrics/perf_provider_chrome_os: 26 27 add: 28 #include "third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h" 29 30 Change the perf profiling interval to something small (60*1000 milliseconds). 31 32 inside DoPeriodicCollection, insert the following code: 33 34 std::string output; 35 char* chr_arr = new char[9999]; 36 MallocExtension::instance() ->GetHeapSample(&output); 37 MallocExtension::instance() ->GetStats(chr_arr, 9999); 38 LOG(ERROR) << "Output Heap Data: "; 39 LOG(ERROR) << output; 40 LOG(ERROR) << "Output Heap Stats: "; 41 output = ""; 42 for (unsigned int i = 0; i < strlen(chr_arr); i++) { 43 output += chr_arr[i]; 44 } 45 LOG(ERROR) << output; 46 delete[] chr_arr; 47