Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Probably Memory Leak with sf::RenderWindow  (Read 3772 times)

0 Members and 1 Guest are viewing this topic.

scorcher24

  • Newbie
  • *
  • Posts: 9
    • ICQ Messenger - 78951707
    • View Profile
Probably Memory Leak with sf::RenderWindow
« on: March 26, 2009, 02:31:14 am »
Adding this code to my program while using WindowsXP SP3 and Visual Studio 2008 Express results in a memory leak.
Code: [Select]

sf::RenderWindow m_window;


Code: [Select]

Detected memory leaks!
Dumping objects ->
{123} normal block at 0x016A6660, 20 bytes long.
 Data: <`fj `fj `fj     > 60 66 6A 01 60 66 6A 01 60 66 6A 01 CD CD CD CD
{122} normal block at 0x016A6548, 216 bytes long.
 Data: < u              > AC 75 86 00 01 00 00 00 01 00 00 00 00 00 00 00
{121} normal block at 0x016A6508, 4 bytes long.
 Data: <Hej > 48 65 6A 01
Object dump complete.


Memory report is achieved with:
Code: [Select]

#if defined (_DEBUG) && defined(_MSC_VER)
            long flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
            flag |= _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_ALWAYS_DF;
            _CrtSetDbgFlag(flag);
#endif /* _MSC_VER && _DEBUG */

I have debugged my own application from begin() to end() and if I remove the sfml-code, there are no more leaks. So I can safely say, that it is coming from sfml.
regards.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Probably Memory Leak with sf::RenderWindow
« Reply #1 on: March 26, 2009, 07:48:34 am »
Weird. The RenderWindow default constructor does nothing, and the constructors of its members (including the base classes ones) do nothing as well (there are only primitive types).

Is it happening with this minimal piece of code?
Code: [Select]
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow w;
    return 0;
}
Laurent Gomila - SFML developer

scorcher24

  • Newbie
  • *
  • Posts: 9
    • ICQ Messenger - 78951707
    • View Profile
Probably Memory Leak with sf::RenderWindow
« Reply #2 on: March 26, 2009, 08:45:48 am »
Quote from: "Laurent"
Weird. The RenderWindow default constructor does nothing, and the constructors of its members (including the base classes ones) do nothing as well (there are only primitive types).

Is it happening with this minimal piece of code?
Code: [Select]
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow w;
    return 0;
}


Yes, it is happening.

Quote from: "Debugger"

"test.exe": "X:\Projects\test\Debug\test.exe" geladen, Symbole wurden geladen.
"test.exe": "C:\WINDOWS\system32\ntdll.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\kernel32.dll" wurde geladen
"test.exe": "X:\Projects\test\sfml-graphics-d.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\opengl32.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\msvcrt.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\advapi32.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\rpcrt4.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\secur32.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\gdi32.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\user32.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\glu32.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\ddraw.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\dciman32.dll" wurde geladen
"test.exe": "X:\Projects\test\sfml-window-d.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\winmm.dll" wurde geladen
"test.exe": "X:\Projects\test\sfml-system-d.dll" wurde geladen
"test.exe": "C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.30729.1_x-ww_f863c71f\msvcp90d.dll" wurde geladen
"test.exe": "C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.30729.1_x-ww_f863c71f\msvcr90d.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\imm32.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\dinput.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\hid.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\setupapi.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\wintrust.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\crypt32.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\msasn1.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\imagehlp.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\uxtheme.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\msctf.dll" wurde geladen
"test.exe": "C:\Programme\Logitech\SetPoint\GameHook.dll" wurde geladen
"test.exe": "C:\Programme\Logitech\SetPoint\lgscroll.dll" wurde geladen
"test.exe": "C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.3053_x-ww_b80fa8ca\msvcr80.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\ntmarta.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\ole32.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\samlib.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\wldap32.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\msctfime.ime" wurde geladen
"test.exe": "C:\WINDOWS\system32\nvoglnt.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\mcd32.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\mcd32.dll" entladen.
Der Thread 'Win32 Thread' (0xe34) hat mit Code 0 (0x0) geendet.
"test.exe": "C:\WINDOWS\system32\version.dll" wurde geladen
"test.exe": "C:\WINDOWS\system32\version.dll" entladen.
Der Thread 'Win32 Thread' (0x890) hat mit Code 0 (0x0) geendet.
Der Thread 'Win32 Thread' (0x1030) hat mit Code 0 (0x0) geendet.
Detected memory leaks!
Dumping objects ->
{122} normal block at 0x013365C8, 20 bytes long.
 Data: < e3  e3  e3     > C8 65 33 01 C8 65 33 01 C8 65 33 01 CD CD CD CD
{121} normal block at 0x013364B0, 216 bytes long.
 Data: < u8             > AC 75 38 00 01 00 00 00 01 00 00 00 00 00 00 00
{120} normal block at 0x01336470, 4 bytes long.
 Data: < d3 > B0 64 33 01
Object dump complete.


(Sorry, its the German version :D)
Code:
Code: [Select]


#include <sfml/Graphics.hpp>


int main()
{
#if defined (_DEBUG) && defined(_MSC_VER)
            long flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
            flag |= _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_ALWAYS_DF;
            _CrtSetDbgFlag(flag);
#endif /* _MSC_VER && _DEBUG */
    sf::RenderWindow window;
return 0;
}



There are 2 Things which is remarkable:
* It is ALWAYS the same amount of memory which is leaking.
* With 216 Byte in the second chunk it is quite large... more than a "common" class needs normally. Much more.
What version of Visual Studio was this SDK linked against? Perhaps that is the problem. The binaries are marked with VC8, I am using VC9. Could this produce this problem?
Edit: I was wrong, the folder is called "VC2008". So this should be ok.
So long.
rya.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Probably Memory Leak with sf::RenderWindow
« Reply #3 on: March 26, 2009, 10:30:44 am »
Ok, I'll try this piece of code at home. Thanks for your help :)
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Probably Memory Leak with sf::RenderWindow
« Reply #4 on: April 10, 2009, 04:10:02 pm »
I've tried the exact same code under VS2005, using the latest sources, and everything's fine.
Laurent Gomila - SFML developer