add a conveniant way to detect memory leaks in Visual Studio

#ifdef'ed out for other built types.

MSVC's built-in memory leak detection is of limited capability due
to conflicts with placement new and missing stacktraces or even line
numbers.

This method uses the Visual Leak Detector http://www.vld.codeplex.com
LGPL'ed; I recommend setting StartDisabled = yes and
AggregateDuplicates = yes. This reduces a bit the noise caused by
static pointers initialized with new. There are a lot of leaks
reported for which I don't know whether they are some sort of false
positives.  I hope they vanish once that someone cleans up the
valgrind log. :)
This commit is contained in:
Anonymissimus 2011-11-18 19:58:13 +00:00
parent 6ac1945c3e
commit 7aaa729698

View file

@ -43,6 +43,10 @@
#include <boost/iostreams/copy.hpp>
#include <boost/iostreams/filter/gzip.hpp>
#ifdef HAVE_VISUAL_LEAK_DETECTOR
#include "vld.h"
#endif
// Minimum stack cookie to prevent stack overflow on AmigaOS4
#ifdef __amigaos4__
const char __attribute__((used)) stackcookie[] = "\0$STACK: 16000000";
@ -586,6 +590,11 @@ void init_custom_malloc();
int main(int argc, char** argv)
{
#ifdef HAVE_VISUAL_LEAK_DETECTOR
VLDEnable();
#endif
#if defined(_OPENMP) && !defined(_WIN32) && !defined(__APPLE__)
// Wesnoth is a special case for OMP
// OMP wait strategy is to have threads busy-loop for 100ms