Chromium Code Reviews| Index: base/debug/proc_maps_linux.cc |
| diff --git a/base/debug/proc_maps_linux.cc b/base/debug/proc_maps_linux.cc |
| index 9557feb025994b1e88763b3c52f855127eaeda81..562189ff72b9c90470a343d06b4626bda1476a30 100644 |
| --- a/base/debug/proc_maps_linux.cc |
| +++ b/base/debug/proc_maps_linux.cc |
| @@ -22,7 +22,20 @@ |
| namespace base { |
| namespace debug { |
| +// Local testing revealed that the size of /proc/<pid>/maps for an official |
| +// release build of chrome hovered around the ~45 KB mark with some processes |
| +// hitting 80-90 KB. We'll play it safe and use 256 KB. |
| +enum { kLargeProcMapsSize = 256 * 1024 }; |
|
Mark Mentovai
2013/07/11 03:47:50
Why an enum? Why not a const?
And why is it out h
|
| + |
| bool ReadProcMaps(std::string* proc_maps) { |
| + // It's possible for /proc/self/maps to change during reading (e.g., when |
| + // running under ThreadSanitizer). Resize |proc_maps| to be large enough |
| + // to read without causing a reallocation. |
| + // |
| + // Refer to http://crbug.com/258451 for details. |
| + proc_maps->clear(); |
| + proc_maps->reserve(kLargeProcMapsSize); |
|
Mark Mentovai
2013/07/11 03:47:50
How is this supposed to help…?
|
| + |
| FilePath proc_maps_path("/proc/self/maps"); |
| return file_util::ReadFileToString(proc_maps_path, proc_maps); |
|
Mark Mentovai
2013/07/11 03:47:50
…file_util::ReadFileToString still reads chunks of
Alexander Potapenko
2013/07/11 10:28:54
Maybe base::MemoryMappedFile could be used instead
Mark Mentovai
2013/07/11 14:20:40
Alexander Potapenko wrote:
|
| } |