VTK
vtkDebugLeaks.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkDebugLeaks.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
49#ifndef vtkDebugLeaks_h
50#define vtkDebugLeaks_h
51
52#include "vtkCommonCoreModule.h" // For export macro
53#include "vtkObject.h"
54
55#include "vtkToolkits.h" // Needed for VTK_DEBUG_LEAKS macro setting.
56#include "vtkDebugLeaksManager.h" // Needed for proper singleton initialization
57
58class vtkDebugLeaksHashTable;
61
62class VTKCOMMONCORE_EXPORT vtkDebugLeaks : public vtkObject
63{
64public:
65 static vtkDebugLeaks *New();
66 vtkTypeMacro(vtkDebugLeaks,vtkObject);
67
71 static void ConstructClass(const char* classname);
72
76 static void DestructClass(const char* classname);
77
82 static int PrintCurrentLeaks();
83
85
89 static int GetExitError();
90 static void SetExitError(int);
92
95
96protected:
98 ~vtkDebugLeaks() VTK_OVERRIDE{}
99
100 static int DisplayMessageBox(const char*);
101
102 static void ClassInitialize();
103 static void ClassFinalize();
104
105 static void ConstructingObject(vtkObjectBase* object);
106 static void DestructingObject(vtkObjectBase* object);
107
109 friend class vtkObjectBase;
110
111private:
112 static vtkDebugLeaksHashTable* MemoryTable;
113 static vtkSimpleCriticalSection* CriticalSection;
114 static vtkDebugLeaksObserver* Observer;
115 static int ExitError;
116
117 vtkDebugLeaks(const vtkDebugLeaks&) VTK_DELETE_FUNCTION;
118 void operator=(const vtkDebugLeaks&) VTK_DELETE_FUNCTION;
119};
120
121// This class defines callbacks for debugging tools. The callbacks are not for general use.
122// The objects passed as arguments to the callbacks are in partially constructed or destructed
123// state and accessing them may cause undefined behavior.
124class VTKCOMMONCORE_EXPORT vtkDebugLeaksObserver {
125public:
129};
130
131#endif // vtkDebugLeaks_h
132// VTK-HeaderTest-Exclude: vtkDebugLeaks.h
Manages the vtkDebugLeaks singleton.
virtual void DestructingObject(vtkObjectBase *)=0
virtual ~vtkDebugLeaksObserver()
virtual void ConstructingObject(vtkObjectBase *)=0
identify memory leaks at program termination vtkDebugLeaks is used to report memory leaks at the exit...
Definition: vtkDebugLeaks.h:63
~vtkDebugLeaks() override
Definition: vtkDebugLeaks.h:98
static void SetExitError(int)
static void ConstructingObject(vtkObjectBase *object)
static void ClassInitialize()
static void SetDebugLeaksObserver(vtkDebugLeaksObserver *observer)
static int PrintCurrentLeaks()
Print all the values in the table.
static int DisplayMessageBox(const char *)
static void DestructClass(const char *classname)
Call this when deleting a class of a given name.
static void DestructingObject(vtkObjectBase *object)
static int GetExitError()
Get/Set flag for exiting with an error when leaks are present.
static vtkDebugLeaks * New()
static vtkDebugLeaksObserver * GetDebugLeaksObserver()
static void ConstructClass(const char *classname)
Call this when creating a class of a given name.
static void ClassFinalize()
abstract base class for most VTK objects
Definition: vtkObjectBase.h:66
void operator=(const vtkObjectBase &)
abstract base class for most VTK objects
Definition: vtkObject.h:60
Critical section locking class.