diff options
author | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-29 15:53:26 +0000 |
---|---|---|
committer | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-29 15:53:26 +0000 |
commit | e288a8e7c2b0b1faf93d925128c84620a044bdba (patch) | |
tree | 89495ea3ff186ddf0e0d0763ce6467526756d124 /base | |
parent | 0dbf657461ad991e09707c4ee7e1f9f3000903e4 (diff) | |
download | chromium_src-e288a8e7c2b0b1faf93d925128c84620a044bdba.zip chromium_src-e288a8e7c2b0b1faf93d925128c84620a044bdba.tar.gz chromium_src-e288a8e7c2b0b1faf93d925128c84620a044bdba.tar.bz2 |
Support for showing memory usage of 64-bit IE in a 32-bit Chromium
This is a changelist for http://codereview.chromium.org/75031 by Kent Tamura (tkent@google.com)
Review URL: http://codereview.chromium.org/100111
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14846 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/process_util_win.cc | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/base/process_util_win.cc b/base/process_util_win.cc index fc05664..45a23e8 100644 --- a/base/process_util_win.cc +++ b/base/process_util_win.cc @@ -524,21 +524,30 @@ void ProcessMetrics::GetCommittedKBytes(CommittedKBytes* usage) const { 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; |