Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(571)

Unified Diff: content/renderer/render_thread_impl.cc

Issue 2565273002: Make GetMallocUsages to check only the default process heap. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_thread_impl.cc
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc
index e3aee0fd6f46bee0e35485858d28fcbd722ddfcf..4e1eb8ca5d87a2c5d7ef77dd31e31ccb081d080c 100644
--- a/content/renderer/render_thread_impl.cc
+++ b/content/renderer/render_thread_impl.cc
@@ -1809,31 +1809,20 @@ void RenderThreadImpl::OnProcessPurgeAndSuspend() {
namespace {
static size_t GetMallocUsage() {
- DWORD number_of_heaps = ::GetProcessHeaps(0, NULL);
- if (number_of_heaps <= 0)
+ // Only checks the default process heap.
+ HANDLE heap = ::GetProcessHeap();
+ if (heap == NULL)
return 0;
-
+ if (!::HeapLock(heap))
+ return 0 ;
size_t malloc_usage = 0;
- std::unique_ptr<HANDLE[]> heaps(new HANDLE[number_of_heaps]);
- // If some heaps were gone between the first GetProcessHeaps and here,
- // GetProcessHeaps obtains small number of heaps.
- // If some new heaps were available between the first GetProcessHeaps and
- // here, GetProcessHeaps returns larger number than number_of_heaps.
- // So we need to see min(number_of_obtained_heaps, number_of_heaps).
- DWORD number_of_obtained_heaps =
- ::GetProcessHeaps(number_of_heaps, heaps.get());
- for (size_t i = 0; i < number_of_heaps && i < number_of_obtained_heaps; i++) {
- PROCESS_HEAP_ENTRY heap_entry;
- ::HeapLock(heaps[i]);
- heap_entry.lpData = NULL;
- while (::HeapWalk(heaps[i], &heap_entry) != 0) {
- if (heap_entry.lpData == heaps.get())
- continue;
- if ((heap_entry.wFlags & PROCESS_HEAP_ENTRY_BUSY) != 0)
- malloc_usage += heap_entry.cbData;
- }
- ::HeapUnlock(heaps[i]);
+ PROCESS_HEAP_ENTRY heap_entry;
+ heap_entry.lpData = NULL;
+ while (::HeapWalk(heap, &heap_entry) != 0) {
+ if ((heap_entry.wFlags & PROCESS_HEAP_ENTRY_BUSY) != 0)
+ malloc_usage += heap_entry.cbData;
}
+ ::HeapUnlock(heap);
return malloc_usage;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698