Memory leak using LoadIrrFile vc9 example
Memory leak using LoadIrrFile vc9 example
This is my first post, I can normally find the answer with a little searching! This seems a bit odd to me however and haven't been able to find anything similar.
Using the LoadIrrFile example I have it loading a scene I created with IrrEdit. The scene is very simple with a skybox, terrain, cube and a .lwo mesh.
I run loadIrrFile in debug mode with d3d9 debugging turned on. All seems OK the simple scene loads and runs as it should. When I exit I get "Total Memory Unfreed From Current Process = 528868 bytes" in the debug output.
I have noticed that if I do not move around in the scene much the memory leak does not happen. If I delete the .lwo mesh the leak never happens.
It seems like a safe bet that the problem is with the .lwo file but I have no idea where to start looking or what to look for.
Could someone possibly give me some clue about what to try?
Thanks
Using the LoadIrrFile example I have it loading a scene I created with IrrEdit. The scene is very simple with a skybox, terrain, cube and a .lwo mesh.
I run loadIrrFile in debug mode with d3d9 debugging turned on. All seems OK the simple scene loads and runs as it should. When I exit I get "Total Memory Unfreed From Current Process = 528868 bytes" in the debug output.
I have noticed that if I do not move around in the scene much the memory leak does not happen. If I delete the .lwo mesh the leak never happens.
It seems like a safe bet that the problem is with the .lwo file but I have no idea where to start looking or what to look for.
Could someone possibly give me some clue about what to try?
Thanks
This is looking more like a bug than a newb problem! I created a very simple cube mesh, exported it as an obj file and have the exact same problem.
I did find that if I deleted the terrain from my scene the mem leak went away. So I loaded up the TerrainRendering VC9 example and ran it. With no changes to the code at all It has this same, large memory leak.
A little bit of guidance would really be helpful. It is very difficult to get started with a new engine.
Is there a serious problem with the Irrlicht terrain renderer? Am I failing to release something that should be released when a terrain is loaded? If yes to last is the TerrainRendering example suffering from the same problem?
I did find that if I deleted the terrain from my scene the mem leak went away. So I loaded up the TerrainRendering VC9 example and ran it. With no changes to the code at all It has this same, large memory leak.
A little bit of guidance would really be helpful. It is very difficult to get started with a new engine.
Is there a serious problem with the Irrlicht terrain renderer? Am I failing to release something that should be released when a terrain is loaded? If yes to last is the TerrainRendering example suffering from the same problem?
I can't reproduce it with valgrind, but I also didn't hear about a large memory leak there so far. Anyone else who can reproduce this?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
I just extracted the original Irrlicht.dll and Irrlicht.lib from the irrlicht-1.6.zip just to make sure that I didn't introduce this problem.
I then loaded TerrainRendering_vc9.vcproj into Visual C++ 2008 Express, ran it in debug mode and the problem remains.
With the irr scene I originally ask about, I had to move the camera around before this problem would show up. You may want to give that a try in the terrain example if you still can't reproduce the problem.
I've included a few of the errors from my output window below. The list is far to long to list all of them. Below the error list I've pasted my build log.
Direct3D9: (INFO) :MemFini!
Direct3D9: (WARN) :Memory still allocated! Alloc count = 111
Direct3D9: (WARN) :Current Process (pid) = 00000964
Direct3D9: (WARN) :Memory Address: 003654e8 lAllocID=1 dwSize=000047f8, (pid=00000964)
Direct3D9: (WARN) : Stack Back Trace
Direct3D9: (ERROR) : [0] : Address 00B0E4CB
Direct3D9: (ERROR) : [1] : Address 00B0E59B
Direct3D9: (ERROR) : [2] : Address 00B0E440
Direct3D9: (ERROR) : [3] : Address 00B02DB4
Direct3D9: (ERROR) : [4] : Address 4FDFAF2E
Direct3D9: (ERROR) : [5] : Address 100590C0
Direct3D9: (ERROR) : [6] : Address 00000000
Direct3D9: (ERROR) : [7] : Address 00000000
Direct3D9: (ERROR) : [8] : Address 00000000
Direct3D9: (ERROR) : [9] : Address 00000000
Direct3D9: (ERROR) : [10] : Address 00000000
Direct3D9: (ERROR) : [11] : Address 00000000
Direct3D9: (ERROR) : [12] : Address 00000000
Direct3D9: (ERROR) : [13] : Address 00000000
Direct3D9: (ERROR) : [14] : Address 00000000
Direct3D9: (ERROR) : [15] : Address 00000000
Direct3D9: (WARN) :Memory Address: 0036ce68 lAllocID=22 dwSize=00001a28, (pid=00000964)
Direct3D9: (WARN) : Stack Back Trace
Direct3D9: (ERROR) : [0] : Address 00B050D4
Direct3D9: (ERROR) : [1] : Address 00B05EBF
Direct3D9: (ERROR) : [2] : Address 00B065F8
Direct3D9: (ERROR) : [3] : Address 00B02DD5
Direct3D9: (ERROR) : [4] : Address 4FDFAF2E
Direct3D9: (ERROR) : [5] : Address 100590C0
Direct3D9: (ERROR) : [6] : Address 00000000
Direct3D9: (ERROR) : [7] : Address 00000000
Direct3D9: (ERROR) : [8] : Address 00000000
Direct3D9: (ERROR) : [9] : Address 00000000
Direct3D9: (ERROR) : [10] : Address 00000000
Direct3D9: (ERROR) : [11] : Address 00000000
Direct3D9: (ERROR) : [12] : Address 00000000
Direct3D9: (ERROR) : [13] : Address 00000000
Direct3D9: (ERROR) : [14] : Address 00000000
Direct3D9: (ERROR) : [15] : Address 00000000... on and on...
Direct3D9: (WARN) :Total Memory Unfreed From Current Process = 528868 bytes
The program '[2404] 12.TerrainRendering.exe: Native' has exited with code 0 (0x0).
Build Log Command Lines:
Creating temporary file "c:\Dev-Vis9Cpp\Irrlicht\irrlicht-1.6\examples\12.TerrainRendering\Debug\RSP00000529601604.rsp" with contents
[
/Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_VC80_UPGRADE=0x0710" /D "_MBCS" /FD /EHsc /RTC1 /MTd /Fp".\Debug/TerrainRendering.pch" /Fo".\Debug/" /Fd".\Debug/" /W3 /c /ZI ".\main.cpp"
]
Creating command line "cl.exe @"c:\Dev-Vis9Cpp\Irrlicht\irrlicht-1.6\examples\12.TerrainRendering\Debug\RSP00000529601604.rsp" /nologo /errorReport:prompt"
Creating temporary file "c:\Dev-Vis9Cpp\Irrlicht\irrlicht-1.6\examples\12.TerrainRendering\Debug\RSP00000629601604.rsp" with contents
[
/OUT:"..\..\bin\Win32-VisualStudio\12.TerrainRendering.exe" /LIBPATH:"..\..\lib\Win32-visualstudio" /MANIFEST /MANIFESTFILE:".\Debug\12.TerrainRendering.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:".\Debug/TerrainRendering.pdb" /SUBSYSTEM:CONSOLE /DYNAMICBASE:NO /MACHINE:X86 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
".\Debug\main.obj"
]
Creating command line "link.exe @"c:\Dev-Vis9Cpp\Irrlicht\irrlicht-1.6\examples\12.TerrainRendering\Debug\RSP00000629601604.rsp" /NOLOGO /ERRORREPORT:PROMPT"
Creating temporary file "c:\Dev-Vis9Cpp\Irrlicht\irrlicht-1.6\examples\12.TerrainRendering\Debug\RSP00000729601604.rsp" with contents
[
/outputresource:"..\..\bin\Win32-VisualStudio\12.TerrainRendering.exe;#1" /manifest
".\Debug\12.TerrainRendering.exe.intermediate.manifest"
]
Creating command line "mt.exe @"c:\Dev-Vis9Cpp\Irrlicht\irrlicht-1.6\examples\12.TerrainRendering\Debug\RSP00000729601604.rsp" /nologo"
Creating temporary file "c:\Dev-Vis9Cpp\Irrlicht\irrlicht-1.6\examples\12.TerrainRendering\Debug\BAT00000829601604.bat" with contents
[
@echo Manifest resource last updated at %TIME% on %DATE% > ".\Debug\mt.dep"
]
Creating command line """c:\Dev-Vis9Cpp\Irrlicht\irrlicht-1.6\examples\12.TerrainRendering\Debug\BAT00000829601604.bat"""
I then loaded TerrainRendering_vc9.vcproj into Visual C++ 2008 Express, ran it in debug mode and the problem remains.
With the irr scene I originally ask about, I had to move the camera around before this problem would show up. You may want to give that a try in the terrain example if you still can't reproduce the problem.
I've included a few of the errors from my output window below. The list is far to long to list all of them. Below the error list I've pasted my build log.
Direct3D9: (INFO) :MemFini!
Direct3D9: (WARN) :Memory still allocated! Alloc count = 111
Direct3D9: (WARN) :Current Process (pid) = 00000964
Direct3D9: (WARN) :Memory Address: 003654e8 lAllocID=1 dwSize=000047f8, (pid=00000964)
Direct3D9: (WARN) : Stack Back Trace
Direct3D9: (ERROR) : [0] : Address 00B0E4CB
Direct3D9: (ERROR) : [1] : Address 00B0E59B
Direct3D9: (ERROR) : [2] : Address 00B0E440
Direct3D9: (ERROR) : [3] : Address 00B02DB4
Direct3D9: (ERROR) : [4] : Address 4FDFAF2E
Direct3D9: (ERROR) : [5] : Address 100590C0
Direct3D9: (ERROR) : [6] : Address 00000000
Direct3D9: (ERROR) : [7] : Address 00000000
Direct3D9: (ERROR) : [8] : Address 00000000
Direct3D9: (ERROR) : [9] : Address 00000000
Direct3D9: (ERROR) : [10] : Address 00000000
Direct3D9: (ERROR) : [11] : Address 00000000
Direct3D9: (ERROR) : [12] : Address 00000000
Direct3D9: (ERROR) : [13] : Address 00000000
Direct3D9: (ERROR) : [14] : Address 00000000
Direct3D9: (ERROR) : [15] : Address 00000000
Direct3D9: (WARN) :Memory Address: 0036ce68 lAllocID=22 dwSize=00001a28, (pid=00000964)
Direct3D9: (WARN) : Stack Back Trace
Direct3D9: (ERROR) : [0] : Address 00B050D4
Direct3D9: (ERROR) : [1] : Address 00B05EBF
Direct3D9: (ERROR) : [2] : Address 00B065F8
Direct3D9: (ERROR) : [3] : Address 00B02DD5
Direct3D9: (ERROR) : [4] : Address 4FDFAF2E
Direct3D9: (ERROR) : [5] : Address 100590C0
Direct3D9: (ERROR) : [6] : Address 00000000
Direct3D9: (ERROR) : [7] : Address 00000000
Direct3D9: (ERROR) : [8] : Address 00000000
Direct3D9: (ERROR) : [9] : Address 00000000
Direct3D9: (ERROR) : [10] : Address 00000000
Direct3D9: (ERROR) : [11] : Address 00000000
Direct3D9: (ERROR) : [12] : Address 00000000
Direct3D9: (ERROR) : [13] : Address 00000000
Direct3D9: (ERROR) : [14] : Address 00000000
Direct3D9: (ERROR) : [15] : Address 00000000... on and on...
Direct3D9: (WARN) :Total Memory Unfreed From Current Process = 528868 bytes
The program '[2404] 12.TerrainRendering.exe: Native' has exited with code 0 (0x0).
Build Log Command Lines:
Creating temporary file "c:\Dev-Vis9Cpp\Irrlicht\irrlicht-1.6\examples\12.TerrainRendering\Debug\RSP00000529601604.rsp" with contents
[
/Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_VC80_UPGRADE=0x0710" /D "_MBCS" /FD /EHsc /RTC1 /MTd /Fp".\Debug/TerrainRendering.pch" /Fo".\Debug/" /Fd".\Debug/" /W3 /c /ZI ".\main.cpp"
]
Creating command line "cl.exe @"c:\Dev-Vis9Cpp\Irrlicht\irrlicht-1.6\examples\12.TerrainRendering\Debug\RSP00000529601604.rsp" /nologo /errorReport:prompt"
Creating temporary file "c:\Dev-Vis9Cpp\Irrlicht\irrlicht-1.6\examples\12.TerrainRendering\Debug\RSP00000629601604.rsp" with contents
[
/OUT:"..\..\bin\Win32-VisualStudio\12.TerrainRendering.exe" /LIBPATH:"..\..\lib\Win32-visualstudio" /MANIFEST /MANIFESTFILE:".\Debug\12.TerrainRendering.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:".\Debug/TerrainRendering.pdb" /SUBSYSTEM:CONSOLE /DYNAMICBASE:NO /MACHINE:X86 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
".\Debug\main.obj"
]
Creating command line "link.exe @"c:\Dev-Vis9Cpp\Irrlicht\irrlicht-1.6\examples\12.TerrainRendering\Debug\RSP00000629601604.rsp" /NOLOGO /ERRORREPORT:PROMPT"
Creating temporary file "c:\Dev-Vis9Cpp\Irrlicht\irrlicht-1.6\examples\12.TerrainRendering\Debug\RSP00000729601604.rsp" with contents
[
/outputresource:"..\..\bin\Win32-VisualStudio\12.TerrainRendering.exe;#1" /manifest
".\Debug\12.TerrainRendering.exe.intermediate.manifest"
]
Creating command line "mt.exe @"c:\Dev-Vis9Cpp\Irrlicht\irrlicht-1.6\examples\12.TerrainRendering\Debug\RSP00000729601604.rsp" /nologo"
Creating temporary file "c:\Dev-Vis9Cpp\Irrlicht\irrlicht-1.6\examples\12.TerrainRendering\Debug\BAT00000829601604.bat" with contents
[
@echo Manifest resource last updated at %TIME% on %DATE% > ".\Debug\mt.dep"
]
Creating command line """c:\Dev-Vis9Cpp\Irrlicht\irrlicht-1.6\examples\12.TerrainRendering\Debug\BAT00000829601604.bat"""
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
The problem could be with VBOs under Direct3D. I cannot really test memory leaks under Windows, and honestly this output is also far from being helpful. Try to set a breakpoint in the HW Buffer cleanup code to see whether they are freed. However, this might also be a non-problem as long as they are only not freed in the end.
I think the output may be useful to the OP. If the OP runs the app once to get the output and then uses Break On Alloc ID - specifying one of the leaky AllocID's in the output - then the call stack should point exactly to the culprit.hybrid wrote: and honestly this output is also far from being helpful
Irrlicht Demos: http://irrlicht.sourceforge.net/forum/viewtopic.php?f=6&t=45781
The culprit in this case is the d3d object and d3d device. The first Alloc ID is 1 which breaks at pID3D = (*d3dCreate)(D3D_SDK_VERSION); in CD3D9Driver.cpp.
I think all of these D3D debug errors are popping up simply because the D3D obj. and device are being released in the destructor instead of a cleanup function before the destuctor. I'm not sure why this is but I've ran across it before in D3D programming. It probably has to do with when d3d debug checks the reference count.
hybrid is right, it's probably a non issue except it makes it very difficult to detect a real problem when it does pop up.
I think all of these D3D debug errors are popping up simply because the D3D obj. and device are being released in the destructor instead of a cleanup function before the destuctor. I'm not sure why this is but I've ran across it before in D3D programming. It probably has to do with when d3d debug checks the reference count.
hybrid is right, it's probably a non issue except it makes it very difficult to detect a real problem when it does pop up.
It's a memory leak. It's not a non-issue.Pelgar wrote:it's probably a non issue.
Anyway, I was going to track the problem down and fix it but I can't reproduce the memory leak.
I added D3D_DEBUG_INFO to IrrCompileConfig.h and opened up BuildAllExamples and rebuilt everything in Debug. I enabled Debug D3D9 and ran the 12.TerrainRendering_vc9 example: no memory leak in the debug output.
All this tells us is that it leaks for you and doesn't leak for me. I think we need some more people to test this out...
Irrlicht Demos: http://irrlicht.sourceforge.net/forum/viewtopic.php?f=6&t=45781
I just tried to reproduce that, but couldn't so far. Can you give exact steps how you enable that d3d debugging? Or what else you do? It's been a few years since I used VS regularly, so maybe I'm missing out on something.
edit: Hm, on further testing I got one idea... do you quit by closing the console window instead of closing with the Irrlicht window? In that case you will get memory leaks.
edit: Hm, on further testing I got one idea... do you quit by closing the console window instead of closing with the Irrlicht window? In that case you will get memory leaks.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
That's what I was thinking. We can probably catch that event and shut down cleanly, IIRC the Win32 version of the console device catches those.CuteAlien wrote:edit: Hm, on further testing I got one idea... do you quit by closing the console window instead of closing with the Irrlicht window? In that case you will get memory leaks.