Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_memory_leak_tracker.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2010 Cyrille Berger <cberger@cberger.net>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-or-later
5 */
6
7#ifndef _KIS_MEMORY_LEAK_TRACKER_H_
8#define _KIS_MEMORY_LEAK_TRACKER_H_
9
10#include <QtGlobal>
11
12#include <kritaglobal_export.h>
13
14#include <config-memory-leak-tracker.h>
15
16// Only linux support the memory leak tracker
17#ifndef Q_OS_LINUX
18#undef HAVE_MEMORY_LEAK_TRACKER
19#endif
20
21// Disable the memory leak tracker on release build
22#ifdef NDEBUG
23#undef HAVE_MEMORY_LEAK_TRACKER
24#endif
25
34class KRITAGLOBAL_EXPORT KisMemoryLeakTracker
35{
36public:
40 void reference(const void* what, const void* bywho, const char* whatName = 0);
41 void dereference(const void* what, const void* bywho);
42 void dumpReferences();
43 void dumpReferences(const void* what);
44public:
45 template<typename _T_>
46 void reference(const _T_* what, const void* bywho);
47 template<typename _T_>
48 void dereference(const _T_* what, const void* bywho);
49private:
50 struct Private;
51 Private* const d;
52};
53
54#include <typeinfo>
55
56template<typename _T_>
57void KisMemoryLeakTracker::reference(const _T_* what, const void* bywho)
58{
59 reference((void*)what, bywho, typeid(what).name());
60}
61
62template<typename _T_>
63void KisMemoryLeakTracker::dereference(const _T_* what, const void* bywho)
64{
65 dereference((void*)what, bywho);
66}
67
68#endif
PythonPluginManager * instance
void dereference(const void *what, const void *bywho)
void reference(const void *what, const void *bywho, const char *whatName=0)