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

Unified Diff: base/process_util_win.cc

Issue 75031: Support for showing memory usage of 64-bit IE in a 32-bit Chromium process.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 8 months 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 | chrome/browser/memory_details.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process_util_win.cc
===================================================================
--- base/process_util_win.cc (revision 13324)
+++ base/process_util_win.cc (working copy)
@@ -441,21 +441,30 @@
size_t committed_mapped = 0;
size_t committed_image = 0;
void* base_address = NULL;
- while (VirtualQueryEx(process_, base_address, &mbi,
- sizeof(MEMORY_BASIC_INFORMATION)) ==
- sizeof(MEMORY_BASIC_INFORMATION)) {
- if (mbi.State == MEM_COMMIT) {
- if (mbi.Type == MEM_PRIVATE) {
- committed_private += mbi.RegionSize;
- } else if (mbi.Type == MEM_MAPPED) {
- committed_mapped += mbi.RegionSize;
- } else if (mbi.Type == MEM_IMAGE) {
- committed_image += mbi.RegionSize;
- } else {
- NOTREACHED();
- }
+ while (VirtualQueryEx(process_, base_address, &mbi, sizeof(mbi)) ==
+ sizeof(mbi)) {
+ if (mbi.State == MEM_COMMIT) {
+ if (mbi.Type == MEM_PRIVATE) {
+ committed_private += mbi.RegionSize;
+ } else if (mbi.Type == MEM_MAPPED) {
+ committed_mapped += mbi.RegionSize;
+ } else if (mbi.Type == MEM_IMAGE) {
+ committed_image += mbi.RegionSize;
+ } else {
+ NOTREACHED();
}
- base_address = (static_cast<BYTE*>(mbi.BaseAddress)) + mbi.RegionSize;
+ }
+ void* new_base = (static_cast<BYTE*>(mbi.BaseAddress)) + mbi.RegionSize;
+ // Avoid infinite loop by weird MEMORY_BASIC_INFORMATION.
+ // If we query 64bit processes in a 32bit process, VirtualQueryEx()
+ // returns such data.
+ if (new_base <= base_address) {
+ usage->image = 0;
+ usage->mapped = 0;
+ usage->priv = 0;
+ return;
+ }
+ base_address = new_base;
}
usage->image = committed_image / 1024;
usage->mapped = committed_mapped / 1024;
« no previous file with comments | « no previous file | chrome/browser/memory_details.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698