Skip to content

Commit 20b9d22

Browse files
committed
Set _CRTDBG_MAP_ALLOC for vc++ debug mode leak tracking.
1 parent 5a28ad0 commit 20b9d22

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

include/bitcoin/system/preprocessor.hpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,22 @@
3232
/// Debugging.
3333
/// ---------------------------------------------------------------------------
3434

35+
/// Enables ETW tracing for VS memory profiler.
36+
#if defined(HAVE_MSC)
37+
#define ALLOCATOR __declspec(allocator)
38+
#else
39+
#define ALLOCATOR
40+
#endif
41+
42+
/// learn.microsoft.com/en-us/cpp/c-runtime-library/
43+
/// find-memory-leaks-using-the-crt-library
44+
/// _CRTDBG_MAP_ALLOC must be prior to the includes, so defined in props.
45+
#if defined(HAVE_MSC) && defined(_DEBUG) && defined(_CRTDBG_MAP_ALLOC)
46+
#include <stdlib.h>
47+
#include <crtdbg.h>
48+
////_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
49+
#endif
50+
3551
/// NDEBUG (conditional exclusion).
3652
#if defined(NDEBUG)
3753
#define BC_ASSERT(expression)
@@ -44,13 +60,6 @@
4460
#define BC_DEBUG_ONLY(expression) expression
4561
#endif
4662

47-
/// Enables ETW tracing for VS memory profiler.
48-
#if defined(HAVE_MSC)
49-
#define ALLOCATOR __declspec(allocator)
50-
#else
51-
#define ALLOCATOR
52-
#endif
53-
5463
/// Messages.
5564
/// ---------------------------------------------------------------------------
5665

0 commit comments

Comments
 (0)