Add a LeakHunter class which can be enabled with compile-flag _IRR_COMPILE_WITH_LEAK_HUNTER_ to find leaking IReferenceCounted objects.
Will break OSX compiling for now as that project file is not yet updated. I hope other project files are all fixed correctly. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4425 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
f9d0f81342
commit
433445cdc2
|
@ -1,6 +1,7 @@
|
|||
--------------------------
|
||||
Changes in 1.9 (not yet released)
|
||||
|
||||
- Add a LeakHunter class which can be enabled with compile-flag _IRR_COMPILE_WITH_LEAK_HUNTER_ to find leaking IReferenceCounted objects.
|
||||
- Add _IRR_COMPILE_WITH_XML_ define to allow compiling Irrlicht without xml (patch written by curaga)
|
||||
- Add functions to set/get cursor character and blinktime to IGUIEditBox
|
||||
- Collada exporter calculates values for orthographic camera now on export
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
|
||||
#include "irrTypes.h"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_LEAK_HUNTER_
|
||||
#include "leakHunter.h"
|
||||
#endif
|
||||
|
||||
namespace irr
|
||||
{
|
||||
|
||||
|
@ -46,11 +50,17 @@ namespace irr
|
|||
IReferenceCounted()
|
||||
: DebugName(0), ReferenceCounter(1)
|
||||
{
|
||||
#ifdef _IRR_COMPILE_WITH_LEAK_HUNTER_
|
||||
LeakHunter::addObject(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
//! Destructor.
|
||||
virtual ~IReferenceCounted()
|
||||
{
|
||||
#ifdef _IRR_COMPILE_WITH_LEAK_HUNTER_
|
||||
LeakHunter::removeObject(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
//! Grabs the object. Increments the reference counter by one.
|
||||
|
|
|
@ -122,6 +122,13 @@
|
|||
#undef _IRR_COMPILE_WITH_XML_
|
||||
#endif
|
||||
|
||||
//! Add a leak-hunter to Irrlicht which helps finding unreleased reference counted objects.
|
||||
//! NOTE: This is slow and should only be used for debugging
|
||||
//#define _IRR_COMPILE_WITH_LEAK_HUNTER_
|
||||
#ifdef NO_IRR_COMPILE_WITH_LEAK_HUNTER_
|
||||
#undef _IRR_COMPILE_WITH_LEAK_HUNTER_
|
||||
#endif
|
||||
|
||||
//! Define _IRR_COMPILE_WITH_DIRECT3D_8_ and _IRR_COMPILE_WITH_DIRECT3D_9_ to
|
||||
//! compile the Irrlicht engine with Direct3D8 and/or DIRECT3D9.
|
||||
/** If you only want to use the software device or opengl you can disable those defines.
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
// Copyright (C) 2013 Michael Zeilfelder
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#ifndef __LEAK_HUNTER_INCLUDEED__
|
||||
|
||||
#include "IrrCompileConfig.h"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_LEAK_HUNTER_
|
||||
|
||||
#include "irrArray.h"
|
||||
|
||||
namespace irr
|
||||
{
|
||||
class IReferenceCounted;
|
||||
|
||||
//! A calls helping to find unrelease objects of type IReferenceCounted.
|
||||
/** To use this you have recompile Irrlicht with _IRR_COMPILE_WITH_LEAK_HUNTER_.
|
||||
Note that this will slow down your application and should only be used for debugging.
|
||||
The way to use is that you can check after you closed and dropped your last Irrlicht device
|
||||
if there are still any IReferenceCounted left over which have not been deleted.
|
||||
*/
|
||||
class LeakHunter
|
||||
{
|
||||
public:
|
||||
friend class IReferenceCounted;
|
||||
|
||||
//! Clear all IReferenceCounted objects inside LeakHunter
|
||||
/** This does not affect the IReferenceCounted themselfes only the
|
||||
counting of them. Usually you don't ever need to clear, but
|
||||
sometimes it helps when for example you want for to ignore
|
||||
certain leaks.
|
||||
*/
|
||||
static void clearReferenceCountedObjects()
|
||||
{
|
||||
ReferenceCountedObjects.clear();
|
||||
}
|
||||
|
||||
static inline irr::core::array<const IReferenceCounted*> getReferenceCountedObjects()
|
||||
{
|
||||
return ReferenceCountedObjects;
|
||||
}
|
||||
|
||||
protected:
|
||||
static inline void addObject(const IReferenceCounted* object)
|
||||
{
|
||||
ReferenceCountedObjects.push_back(object);
|
||||
}
|
||||
|
||||
static inline void removeObject(const IReferenceCounted* object)
|
||||
{
|
||||
irr::s32 idx = ReferenceCountedObjects.linear_search(object );
|
||||
if ( idx >= 0 )
|
||||
{
|
||||
irr::core::swap( ReferenceCountedObjects[idx], ReferenceCountedObjects.getLast() );
|
||||
ReferenceCountedObjects.erase( ReferenceCountedObjects.size()-1 );
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
// NOTE: We don't do additional grab()/drop()'s here as we want to supervise reference counted objects and not affect them otherwise.
|
||||
IRRLICHT_API static irr::core::array<const IReferenceCounted*> ReferenceCountedObjects;
|
||||
};
|
||||
} // end namespace irr
|
||||
|
||||
#endif // _IRR_COMPILE_WITH_LEAK_HUNTER_
|
||||
|
||||
#endif
|
|
@ -591,6 +591,7 @@
|
|||
<Unit filename="..\..\include\irrlicht.h" />
|
||||
<Unit filename="..\..\include\irrpack.h" />
|
||||
<Unit filename="..\..\include\irrunpack.h" />
|
||||
<Unit filename="..\..\include\leakHunter.h" />
|
||||
<Unit filename="..\..\include\line2d.h" />
|
||||
<Unit filename="..\..\include\line3d.h" />
|
||||
<Unit filename="..\..\include\matrix4.h" />
|
||||
|
@ -1273,6 +1274,7 @@
|
|||
</Unit>
|
||||
<Unit filename="lzma\LzmaDec.h" />
|
||||
<Unit filename="lzma\Types.h" />
|
||||
<Unit filename="leakHunter.cpp" />
|
||||
<Unit filename="os.cpp" />
|
||||
<Unit filename="os.h" />
|
||||
<Unit filename="zlib\adler32.c">
|
||||
|
|
|
@ -1407,6 +1407,7 @@
|
|||
<ClCompile Include="CLogger.cpp" />
|
||||
<ClCompile Include="COSOperator.cpp" />
|
||||
<ClCompile Include="Irrlicht.cpp" />
|
||||
<ClCompile Include="leakHunter.cpp" />
|
||||
<ClCompile Include="os.cpp" />
|
||||
<ClCompile Include="lzma\LzmaDec.c" />
|
||||
<ClCompile Include="zlib\adler32.c" />
|
||||
|
|
|
@ -2243,6 +2243,9 @@
|
|||
<ClCompile Include="CCgMaterialRenderer.cpp">
|
||||
<Filter>Irrlicht\video</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="leakHunter.cpp">
|
||||
<Filter>Irrlicht\irr</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="Irrlicht.rc" />
|
||||
|
|
|
@ -848,6 +848,7 @@
|
|||
<ClInclude Include="..\..\include\IReferenceCounted.h" />
|
||||
<ClInclude Include="..\..\include\IrrCompileConfig.h" />
|
||||
<ClInclude Include="..\..\include\irrlicht.h" />
|
||||
<ClInclude Include="..\..\include\leakHunter.h" />
|
||||
<ClInclude Include="..\..\include\IrrlichtDevice.h" />
|
||||
<ClInclude Include="..\..\include\irrTypes.h" />
|
||||
<ClInclude Include="..\..\include\ITimer.h" />
|
||||
|
@ -1414,6 +1415,7 @@
|
|||
<ClCompile Include="COSOperator.cpp" />
|
||||
<ClCompile Include="Irrlicht.cpp" />
|
||||
<ClCompile Include="os.cpp" />
|
||||
<ClCompile Include="leakHunter.cpp" />
|
||||
<ClCompile Include="lzma\LzmaDec.c" />
|
||||
<ClCompile Include="zlib\adler32.c" />
|
||||
<ClCompile Include="zlib\compress.c" />
|
||||
|
|
|
@ -122,6 +122,9 @@
|
|||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\irrlicht.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\leakHunter.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\IrrlichtDevice.h">
|
||||
<Filter>include</Filter>
|
||||
|
@ -1807,6 +1810,9 @@
|
|||
</ClCompile>
|
||||
<ClCompile Include="os.cpp">
|
||||
<Filter>Irrlicht\irr</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="leakHunter.cpp">
|
||||
<Filter>Irrlicht\irr</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="lzma\LzmaDec.c">
|
||||
<Filter>Irrlicht\irr\extern</Filter>
|
||||
|
|
|
@ -606,6 +606,10 @@
|
|||
RelativePath=".\..\..\include\irrlicht.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\..\include\leakHunter.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\..\..\include\IrrlichtDevice.h"
|
||||
>
|
||||
|
@ -2981,6 +2985,10 @@
|
|||
RelativePath="os.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="leakHunter.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="os.h"
|
||||
>
|
||||
|
|
|
@ -705,6 +705,10 @@
|
|||
RelativePath="..\..\include\irrlicht.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\leakHunter.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\IrrlichtDevice.h"
|
||||
>
|
||||
|
@ -2700,6 +2704,10 @@
|
|||
RelativePath="Irrlicht.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="leakHunter.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="os.cpp"
|
||||
>
|
||||
|
|
|
@ -349,6 +349,10 @@
|
|||
RelativePath="..\..\include\irrlicht.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\leakHunter.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\IrrlichtDevice.h"
|
||||
>
|
||||
|
@ -2554,6 +2558,10 @@
|
|||
RelativePath="os.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="leakHunter.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="os.h"
|
||||
>
|
||||
|
|
|
@ -516,6 +516,9 @@
|
|||
<File
|
||||
RelativePath="..\..\include\irrlicht.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\leakHunter.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\include\IrrlichtDevice.h">
|
||||
</File>
|
||||
|
@ -1419,6 +1422,9 @@
|
|||
<File
|
||||
RelativePath=".\os.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\leakHunter.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\os.h">
|
||||
</File>
|
||||
|
|
|
@ -44,7 +44,7 @@ IRRIMAGEOBJ = CColorConverter.o CImage.o CImageLoaderBMP.o CImageLoaderDDS.o CIm
|
|||
IRRVIDEOOBJ = CVideoModeList.o CFPSCounter.o $(IRRDRVROBJ) $(IRRIMAGEOBJ)
|
||||
IRRSWRENDEROBJ = CSoftwareDriver.o CSoftwareTexture.o CTRFlat.o CTRFlatWire.o CTRGouraud.o CTRGouraudWire.o CTRNormalMap.o CTRStencilShadow.o CTRTextureFlat.o CTRTextureFlatWire.o CTRTextureGouraud.o CTRTextureGouraudAdd.o CTRTextureGouraudNoZ.o CTRTextureGouraudWire.o CZBuffer.o CTRTextureGouraudVertexAlpha2.o CTRTextureGouraudNoZ2.o CTRTextureLightMap2_M2.o CTRTextureLightMap2_M4.o CTRTextureLightMap2_M1.o CSoftwareDriver2.o CSoftwareTexture2.o CTRTextureGouraud2.o CTRGouraud2.o CTRGouraudAlpha2.o CTRGouraudAlphaNoZ2.o CTRTextureDetailMap2.o CTRTextureGouraudAdd2.o CTRTextureGouraudAddNoZ2.o CTRTextureWire2.o CTRTextureLightMap2_Add.o CTRTextureLightMapGouraud2_M4.o IBurningShader.o CTRTextureBlend.o CTRTextureGouraudAlpha.o CTRTextureGouraudAlphaNoZ.o CDepthBuffer.o CBurningShader_Raster_Reference.o
|
||||
IRRIOOBJ = CFileList.o CFileSystem.o CLimitReadFile.o CMemoryFile.o CReadFile.o CWriteFile.o CXMLReader.o CXMLWriter.o CWADReader.o CZipReader.o CPakReader.o CNPKReader.o CTarReader.o CMountPointReader.o irrXML.o CAttributes.o lzma/LzmaDec.o
|
||||
IRROTHEROBJ = CIrrDeviceSDL.o CIrrDeviceLinux.o CIrrDeviceConsole.o CIrrDeviceStub.o CIrrDeviceWin32.o CIrrDeviceFB.o CLogger.o COSOperator.o Irrlicht.o os.o
|
||||
IRROTHEROBJ = CIrrDeviceSDL.o CIrrDeviceLinux.o CIrrDeviceConsole.o CIrrDeviceStub.o CIrrDeviceWin32.o CIrrDeviceFB.o CLogger.o COSOperator.o Irrlicht.o os.o leakHunter.o
|
||||
IRRGUIOBJ = CGUIButton.o CGUICheckBox.o CGUIComboBox.o CGUIContextMenu.o CGUIEditBox.o CGUIEnvironment.o CGUIFileOpenDialog.o CGUIFont.o CGUIImage.o CGUIInOutFader.o CGUIListBox.o CGUIMenu.o CGUIMeshViewer.o CGUIMessageBox.o CGUIModalScreen.o CGUIScrollBar.o CGUISpinBox.o CGUISkin.o CGUIStaticText.o CGUITabControl.o CGUITable.o CGUIToolBar.o CGUIWindow.o CGUIColorSelectDialog.o CDefaultGUIElementFactory.o CGUISpriteBank.o CGUIImageList.o CGUITreeView.o
|
||||
ZLIBOBJ = zlib/adler32.o zlib/compress.o zlib/crc32.o zlib/deflate.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o zlib/uncompr.o zlib/zutil.o
|
||||
JPEGLIBOBJ = jpeglib/jcapimin.o jpeglib/jcapistd.o jpeglib/jccoefct.o jpeglib/jccolor.o jpeglib/jcdctmgr.o jpeglib/jchuff.o jpeglib/jcinit.o jpeglib/jcmainct.o jpeglib/jcmarker.o jpeglib/jcmaster.o jpeglib/jcomapi.o jpeglib/jcparam.o jpeglib/jcprepct.o jpeglib/jcsample.o jpeglib/jctrans.o jpeglib/jdapimin.o jpeglib/jdapistd.o jpeglib/jdatadst.o jpeglib/jdatasrc.o jpeglib/jdcoefct.o jpeglib/jdcolor.o jpeglib/jddctmgr.o jpeglib/jdhuff.o jpeglib/jdinput.o jpeglib/jdmainct.o jpeglib/jdmarker.o jpeglib/jdmaster.o jpeglib/jdmerge.o jpeglib/jdpostct.o jpeglib/jdsample.o jpeglib/jdtrans.o jpeglib/jerror.o jpeglib/jfdctflt.o jpeglib/jfdctfst.o jpeglib/jfdctint.o jpeglib/jidctflt.o jpeglib/jidctfst.o jpeglib/jidctint.o jpeglib/jmemmgr.o jpeglib/jmemnobs.o jpeglib/jquant1.o jpeglib/jquant2.o jpeglib/jutils.o jpeglib/jcarith.o jpeglib/jdarith.o jpeglib/jaricom.o
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright (C) 2013 Michael Zeilfelder
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
#include "leakHunter.h"
|
||||
|
||||
#ifdef _IRR_COMPILE_WITH_LEAK_HUNTER_
|
||||
|
||||
namespace irr
|
||||
{
|
||||
irr::core::array<const IReferenceCounted*> LeakHunter::ReferenceCountedObjects;
|
||||
} // end namespace irr
|
||||
|
||||
#endif // _IRR_COMPILE_WITH_LEAK_HUNTER_
|
||||
|
Loading…
Reference in New Issue