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

Unified Diff: tools/memory_watcher/memory_hook.cc

Issue 366031: Support running memory watch under vista, plus other tweaks... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 | « tools/memory_watcher/memory_hook.h ('k') | tools/memory_watcher/memory_watcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/memory_watcher/memory_hook.cc
===================================================================
--- tools/memory_watcher/memory_hook.cc (revision 31097)
+++ tools/memory_watcher/memory_hook.cc (working copy)
@@ -217,6 +217,7 @@
// block via Perftools_HeapAlloc.
LPVOID rv = Perftools_HeapAlloc(hHeap, dwFlags, dwBytes);
+ DCHECK_EQ((HEAP_REALLOC_IN_PLACE_ONLY & dwFlags), 0);
// If there was an old buffer, now copy the data to the new buffer.
if (lpMem != 0) {
@@ -237,8 +238,10 @@
if (address != NULL) {
MEMORY_BASIC_INFORMATION info;
CHECK(VirtualQuery(address, &info, sizeof(info)));
- if (info.State & MEM_COMMIT)
+ if (info.State & MEM_COMMIT) {
already_committed = true;
+ CHECK(size >= info.RegionSize);
+ }
}
bool reserving = (address == NULL) || (type & MEM_RESERVE);
bool committing = !already_committed && (type & MEM_COMMIT);
@@ -355,6 +358,7 @@
static HGLOBAL WINAPI Perftools_GlobalReAlloc(HGLOBAL hMem, SIZE_T dwBytes,
UINT uFlags) {
+ // TODO(jar): [The following looks like a copy/paste typo from LocalRealloc.]
// GlobalDiscard is a macro which calls LocalReAlloc with size 0.
if (dwBytes == 0) {
return patch_GlobalReAlloc()(hMem, dwBytes, uFlags);
@@ -515,6 +519,9 @@
bool MemoryHook::UnregisterWatcher(MemoryObserver* watcher) {
DCHECK(hooked_);
DCHECK(global_hook_->watcher_ == watcher);
+ // TODO(jar): changing watcher_ here is very racy. Other threads may (without
+ // a lock) testing, and then calling through this value. We probably can't
+ // remove this until we are single threaded.
global_hook_->watcher_ = NULL;
// For now, since there are no more watchers, unhook memory.
« no previous file with comments | « tools/memory_watcher/memory_hook.h ('k') | tools/memory_watcher/memory_watcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698