| OLD | NEW | 
|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include <windows.h> | 5 #include <windows.h> | 
| 6 #include <tlhelp32.h>     // for CreateToolhelp32Snapshot() | 6 #include <tlhelp32.h>     // for CreateToolhelp32Snapshot() | 
| 7 #include <map> | 7 #include <map> | 
| 8 | 8 | 
| 9 #include "tools/memory_watcher/memory_watcher.h" | 9 #include "tools/memory_watcher/memory_watcher.h" | 
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" | 
| 11 #include "base/lock.h" | 11 #include "base/lock.h" | 
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 112     // Ideally, we'd like to verify that the block being added | 112     // Ideally, we'd like to verify that the block being added | 
| 113     // here is not already in our list of tracked blocks.  However, | 113     // here is not already in our list of tracked blocks.  However, | 
| 114     // the lookup in our hash table is expensive and slows us too | 114     // the lookup in our hash table is expensive and slows us too | 
| 115     // much. | 115     // much. | 
| 116     CallStackMap::iterator block_it = block_map_->find(id); | 116     CallStackMap::iterator block_it = block_map_->find(id); | 
| 117     if (block_it != block_map_->end()) { | 117     if (block_it != block_map_->end()) { | 
| 118 #if 0  // Don't do this until stack->ToString() uses ONLY our heap. | 118 #if 0  // Don't do this until stack->ToString() uses ONLY our heap. | 
| 119       active_thread_id_ = GetCurrentThreadId(); | 119       active_thread_id_ = GetCurrentThreadId(); | 
| 120       PrivateAllocatorString output; | 120       PrivateAllocatorString output; | 
| 121       block_it->second->ToString(&output); | 121       block_it->second->ToString(&output); | 
| 122      // LOG(INFO) << "First Stack size " << stack->size() << "was\n" << output; | 122      // VLOG(1) << "First Stack size " << stack->size() << "was\n" << output; | 
| 123       stack->ToString(&output); | 123       stack->ToString(&output); | 
| 124      // LOG(INFO) << "Second Stack size " << stack->size() << "was\n" << output; | 124      // VLOG(1) << "Second Stack size " << stack->size() << "was\n" << output; | 
| 125 #endif  // 0 | 125 #endif  // 0 | 
| 126 | 126 | 
| 127       // TODO(jar): We should delete one stack, and keep the other, perhaps | 127       // TODO(jar): We should delete one stack, and keep the other, perhaps | 
| 128       // based on size. | 128       // based on size. | 
| 129       // For now, just delete the first, and keep the second? | 129       // For now, just delete the first, and keep the second? | 
| 130       delete block_it->second; | 130       delete block_it->second; | 
| 131     } | 131     } | 
| 132     // TODO(jar): Perchance we should use atomic access to member. | 132     // TODO(jar): Perchance we should use atomic access to member. | 
| 133     active_thread_id_ = 0;  // Note: Only do this AFTER exiting above scope! | 133     active_thread_id_ = 0;  // Note: Only do this AFTER exiting above scope! | 
| 134 | 134 | 
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 245     CallStack* stack = stack_track->stack; | 245     CallStack* stack = stack_track->stack; | 
| 246     PrivateAllocatorString output; | 246     PrivateAllocatorString output; | 
| 247     stack->ToString(&output); | 247     stack->ToString(&output); | 
| 248     fprintf(file_, "%s", output.c_str()); | 248     fprintf(file_, "%s", output.c_str()); | 
| 249   } | 249   } | 
| 250   fprintf(file_, "Total Leaks:  %d\n", total_blocks); | 250   fprintf(file_, "Total Leaks:  %d\n", total_blocks); | 
| 251   fprintf(file_, "Total Stacks: %d\n", stack_tracks.size()); | 251   fprintf(file_, "Total Stacks: %d\n", stack_tracks.size()); | 
| 252   fprintf(file_, "Total Bytes:  %d\n", total_bytes); | 252   fprintf(file_, "Total Bytes:  %d\n", total_bytes); | 
| 253   CloseLogFile(); | 253   CloseLogFile(); | 
| 254 } | 254 } | 
| OLD | NEW | 
|---|