license.bot | f003cfe | 2008-08-24 09:55:55 +0900 | [diff] [blame] | 1 | // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 4 | |
| 5 | // Functions used to debug memory usage, leaks, and other memory issues. |
| 6 | // All methods are effectively no-ops unless this program is being run through |
| 7 | // a supported memory tool (currently, only Purify) |
| 8 | |
| 9 | #ifndef BASE_MEMORY_DEBUG_H_ |
mmentovai@google.com | 79ea2c8 | 2008-08-09 05:01:55 +0900 | [diff] [blame] | 10 | #define BASE_MEMORY_DEBUG_H_ |
| 11 | |
| 12 | #include "base/basictypes.h" |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 13 | |
| 14 | namespace base { |
| 15 | |
| 16 | class MemoryDebug { |
mmentovai@google.com | 79ea2c8 | 2008-08-09 05:01:55 +0900 | [diff] [blame] | 17 | public: |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 18 | // Since MIU messages are a lot of data, and we don't always want this data, |
| 19 | // we have a global switch. If disabled, *MemoryInUse are no-ops. |
| 20 | static void SetMemoryInUseEnabled(bool enabled); |
| 21 | |
| 22 | // Dump information about all memory in use. |
| 23 | static void DumpAllMemoryInUse(); |
| 24 | // Dump information about new memory in use since the last |
| 25 | // call to DumpAllMemoryInUse() or DumpNewMemoryInUse(). |
| 26 | static void DumpNewMemoryInUse(); |
| 27 | |
| 28 | // Dump information about all current memory leaks. |
| 29 | static void DumpAllLeaks(); |
| 30 | // Dump information about new memory leaks since the last |
| 31 | // call to DumpAllLeaks() or DumpNewLeaks() |
| 32 | static void DumpNewLeaks(); |
| 33 | |
| 34 | // Mark |size| bytes of memory as initialized, so it doesn't produce any UMRs |
| 35 | // or UMCs. |
| 36 | static void MarkAsInitialized(void* addr, size_t size); |
| 37 | |
mmentovai@google.com | 79ea2c8 | 2008-08-09 05:01:55 +0900 | [diff] [blame] | 38 | private: |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 39 | static bool memory_in_use_; |
mmentovai@google.com | 79ea2c8 | 2008-08-09 05:01:55 +0900 | [diff] [blame] | 40 | |
| 41 | DISALLOW_IMPLICIT_CONSTRUCTORS(MemoryDebug); |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 42 | }; |
| 43 | |
mmentovai@google.com | 79ea2c8 | 2008-08-09 05:01:55 +0900 | [diff] [blame] | 44 | } // namespace base |
initial.commit | 3f4a732 | 2008-07-27 06:49:38 +0900 | [diff] [blame] | 45 | |
mmentovai@google.com | 79ea2c8 | 2008-08-09 05:01:55 +0900 | [diff] [blame] | 46 | #endif // BASE_MEMORY_DEBUG_H_ |