michael@0: // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: michael@0: // Functions used to debug memory usage, leaks, and other memory issues. michael@0: // All methods are effectively no-ops unless this program is being run through michael@0: // a supported memory tool (currently, only Purify) michael@0: michael@0: #ifndef BASE_MEMORY_DEBUG_H_ michael@0: #define BASE_MEMORY_DEBUG_H_ michael@0: michael@0: #include "base/basictypes.h" michael@0: michael@0: namespace base { michael@0: michael@0: class MemoryDebug { michael@0: public: michael@0: // Since MIU messages are a lot of data, and we don't always want this data, michael@0: // we have a global switch. If disabled, *MemoryInUse are no-ops. michael@0: static void SetMemoryInUseEnabled(bool enabled); michael@0: michael@0: // Dump information about all memory in use. michael@0: static void DumpAllMemoryInUse(); michael@0: // Dump information about new memory in use since the last michael@0: // call to DumpAllMemoryInUse() or DumpNewMemoryInUse(). michael@0: static void DumpNewMemoryInUse(); michael@0: michael@0: // Dump information about all current memory leaks. michael@0: static void DumpAllLeaks(); michael@0: // Dump information about new memory leaks since the last michael@0: // call to DumpAllLeaks() or DumpNewLeaks() michael@0: static void DumpNewLeaks(); michael@0: michael@0: // Mark |size| bytes of memory as initialized, so it doesn't produce any UMRs michael@0: // or UMCs. michael@0: static void MarkAsInitialized(void* addr, size_t size); michael@0: michael@0: private: michael@0: static bool memory_in_use_; michael@0: michael@0: DISALLOW_IMPLICIT_CONSTRUCTORS(MemoryDebug); michael@0: }; michael@0: michael@0: } // namespace base michael@0: michael@0: #endif // BASE_MEMORY_DEBUG_H_