Add build option for using Visual Leak Detector for debugging memory leaks. Initial report:

- IfcConvert (no arguments): 2 leaks (140 bytes) (from OCE)
- IfcConvert (acad2010_objects.ifc): 47 memory leaks (6,158 bytes)
- IfcGeomServer: 2 leaks (from OCE)
- IfcOpenHouse: 11,952 leaks (1,169,658 bytes)!
- IfcParseExamples (acad2010_objects.ifc): 40 memory leaks (4,564 bytes)
This commit is contained in:
Stinkfist0
2016-02-07 00:30:08 +02:00
parent 33772a4710
commit cde1c5f2ee
5 changed files with 29 additions and 1 deletions
+4
View File
@@ -28,6 +28,7 @@ OPTION(ENABLE_BUILD_OPTIMIZATIONS "Enable certain compiler and linker optimizati
OPTION(USE_IFC4 "Use IFC 4 instead of IFC 2x3 (full rebuild recommended when switching this)" OFF)
OPTION(BUILD_IFCPYTHON "Build IfcPython." ON)
OPTION(BUILD_EXAMPLES "Build example applications." ON)
OPTION(USE_VLC "Use Visual Leak Detector for debugging memory leaks, MSVC-only." OFF)
# TODO QtViewer is deprecated ATM as it uses the 0.4 API
# OPTION(BUILD_QTVIEWER "Build IfcOpenShell Qt GUI Viewer (requires Qt 4 framework)." OFF)
@@ -237,6 +238,9 @@ if(ENABLE_BUILD_OPTIMIZATIONS)
endif()
IF(MSVC)
IF(USE_VLC)
ADD_DEFINITIONS(-DUSE_VLC)
ENDIF()
# Enforce Unicode for CRT and Win32 API calls
ADD_DEFINITIONS(-D_UNICODE -DUNICODE)
# Disable warnings about unsafe C functions; we could use the safe C99 & C11 versions if we have no need for supporting old compilers.
+6
View File
@@ -41,6 +41,10 @@
#include "../ifcparse/IfcHierarchyHelper.h"
#include "../ifcgeom/IfcGeom.h"
#if USE_VLC
#include <vld.h>
#endif
// Some convenience typedefs and definitions.
typedef std::string S;
typedef IfcParse::IfcGlobalId guid;
@@ -531,6 +535,8 @@ void createGroundShape(TopoDS_Shape& shape) {
TColStd_Array1OfInteger mult(0, 1);
mult(0) = 5;
mult(1) = 5;
#undef new
Handle(Geom_BSplineSurface) surf = new Geom_BSplineSurface(cv, knots, knots, mult, mult, 4, 4);
#if OCC_VERSION_HEX < 0x60502
shape = BRepBuilderAPI_MakeFace(surf);
+4
View File
@@ -19,6 +19,10 @@
#include "../ifcparse/IfcFile.h"
#if USE_VLC
#include <vld.h>
#endif
using namespace IfcSchema;
int main(int argc, char** argv) {
+4
View File
@@ -46,6 +46,10 @@
#include <IGESControl_Controller.hxx>
#include <Standard_Version.hxx>
#if USE_VLC
#include <vld.h>
#endif
static std::string DEFAULT_EXTENSION = "obj";
void printVersion() {
+11 -1
View File
@@ -37,6 +37,10 @@
#include "../ifcgeom/IfcGeomIterator.h"
#if USE_VLC
#include <vld.h>
#endif
using namespace boost;
template <typename T>
@@ -282,7 +286,13 @@ public:
Bye() : Command(BYE) {};
};
int main () {
int main ()
{
// Memory leak debugging in MSVC debug mode
#if defined(_MSC_VER) && defined(_DEBUG)
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif
// Redirect stdout to this stream, so that involuntary
// writes to stdout do not interfere with our protocol.
std::ostringstream oss;