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

Author Topic: Memory Leak relating to RenderWindow & RenderTexture from 2.4.0  (Read 2004 times)

0 Members and 1 Guest are viewing this topic.

Macecraft

  • Guest
Memory Leak relating to RenderWindow & RenderTexture from 2.4.0
« on: October 08, 2016, 11:20:55 pm »
Hello!

So I'm not sure if I'm doing something wrong or if there's an actual issue with 2.4.0. I saw a post( http://en.sfml-dev.org/forums/index.php?topic=20698.msg148631#msg148631) which relates to what I'm about to talk about!

So I use SFML quite frequently and I usually have either VLD (Visual Leak Detector) or the CRT memory leak macros in use in a project. So when I switched from 2.3.2 to 2.4.0 I started noticing more prints about memory leaks in my output windows & to my logs. They always traced back to the creation of a RenderTexture & RenderWindow. So to test if I was doing something wrong I even wrote just this as a program :

int main()
{
        RenderWindow RWindow;
        RWindow.create(VideoMode(640, 480), "Hello", Style::Close);

        while (RWindow.isOpen())
        {
                Event evnt;
                while (RWindow.pollEvent(evnt))
                {
                        if (evnt.type == Event::Closed)
                        {
                                RWindow.close();
                        }
                }
        }

        return 0;
}
 

And this gives me a VLD output of:
Quote
WARNING: Visual Leak Detector detected memory leaks!
---------- Block 15 at 0x00B5EFA8: 52 bytes ----------
  Leak Hash: 0xA46E52FF, Count: 1, Total 52 bytes
  Call Stack (TID 12544):
    ucrtbased.dll!malloc()
    f:\dd\vctools\crt\vcstartup\src\heap\new_scalar.cpp (19): LD36.exe!operator new() + 0x9 bytes
    d:\sfml-release\_sources\sfml\src\sfml\window\glcontext.cpp (182): LD36.exe!sf::priv::GlContext::globalInit() + 0x7 bytes
    d:\sfml-release\_sources\sfml\src\sfml\window\glresource.cpp (56): LD36.exe!sf::GlResource::GlResource()
    d:\sfml-release\_sources\sfml\src\sfml\window\window.cpp (49): LD36.exe!sf::Window::Window() + 0x38 bytes
    d:\sfml-release\_sources\sfml\src\sfml\graphics\renderwindow.cpp (36): LD36.exe!sf::RenderWindow::RenderWindow() + 0x35 bytes
    c:\users\mace\documents\github\get-dat-boaty-post-ld36-\ld36\ld36\sattest.cpp (341): LD36.exe!main() + 0xB bytes
    f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (64): LD36.exe!invoke_main() + 0x1B bytes
    f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (253): LD36.exe!__scrt_common_main_seh() + 0x5 bytes
    f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (296): LD36.exe!__scrt_common_main()
    f:\dd\vctools\crt\vcstartup\src\startup\exe_main.cpp (17): LD36.exe!mainCRTStartup()
    KERNEL32.DLL!BaseThreadInitThunk() + 0x24 bytes
    ntdll.dll!__RtlUserThreadStart() + 0x2F bytes
    ntdll.dll!_RtlUserThreadStart() + 0x1B bytes
  Data:
    00 A7 55 00    18 00 00 00    08 00 00 00    00 00 00 00     ꜀U....
    04 00 00 00    04 00 00 00    00 00 00 00    00 CC CC CC     ....찀쳌
    06 04 27 00    00 00 00 00    26 0C 01 00    00 00 01 00     І'..ద.
    01 CD CD CD                                                  촁췍......


---------- Block 17 at 0x02F9DA98: 52 bytes ----------
  Leak Hash: 0xAC449E57, Count: 1, Total 52 bytes
  Call Stack (TID 12544):
    ucrtbased.dll!malloc()
    f:\dd\vctools\crt\vcstartup\src\heap\new_scalar.cpp (19): LD36.exe!operator new() + 0x9 bytes
    d:\sfml-release\_sources\sfml\src\sfml\window\glcontext.cpp (227): LD36.exe!sf::priv::GlContext::create() + 0x7 bytes
    d:\sfml-release\_sources\sfml\src\sfml\window\context.cpp (62): LD36.exe!sf::Context::Context() + 0x5 bytes
    d:\sfml-release\_sources\sfml\src\sfml\window\glcontext.cpp (159): LD36.exe!`anonymous namespace'::getInternalContext() + 0x22 bytes
    d:\sfml-release\_sources\sfml\src\sfml\window\glcontext.cpp (334): LD36.exe!sf::priv::GlContext::setActive() + 0x7 bytes
    d:\sfml-release\_sources\sfml\src\sfml\window\glcontext.cpp (189): LD36.exe!sf::priv::GlContext::globalInit()
    d:\sfml-release\_sources\sfml\src\sfml\window\glresource.cpp (56): LD36.exe!sf::GlResource::GlResource()
    d:\sfml-release\_sources\sfml\src\sfml\window\window.cpp (49): LD36.exe!sf::Window::Window() + 0x38 bytes
    d:\sfml-release\_sources\sfml\src\sfml\graphics\renderwindow.cpp (36): LD36.exe!sf::RenderWindow::RenderWindow() + 0x35 bytes
    c:\users\mace\documents\github\get-dat-boaty-post-ld36-\ld36\ld36\sattest.cpp (341): LD36.exe!main() + 0xB bytes
    f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (64): LD36.exe!invoke_main() + 0x1B bytes
    f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (253): LD36.exe!__scrt_common_main_seh() + 0x5 bytes
    f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (296): LD36.exe!__scrt_common_main()
    f:\dd\vctools\crt\vcstartup\src\startup\exe_main.cpp (17): LD36.exe!mainCRTStartup()
    KERNEL32.DLL!BaseThreadInitThunk() + 0x24 bytes
    ntdll.dll!__RtlUserThreadStart() + 0x2F bytes
    ntdll.dll!_RtlUserThreadStart() + 0x1B bytes
  Data:
    00 A7 55 00    00 00 00 00    00 00 00 00    00 00 00 00     ꜀U......
    04 00 00 00    04 00 00 00    00 00 00 00    00 CC CC CC     ....찀쳌
    06 04 27 00    6A 04 09 00    97 0C 01 84    01 00 01 00     І'Ѫ   ಗ萁
    00 CD CD CD                                                  촀췍......


---------- Block 16 at 0x02FE1868: 8 bytes ----------
  Leak Hash: 0x415D48D4, Count: 1, Total 8 bytes
  Call Stack (TID 12544):
    ucrtbased.dll!malloc()
    f:\dd\vctools\crt\vcstartup\src\heap\new_scalar.cpp (19): LD36.exe!operator new() + 0x9 bytes
    d:\sfml-release\_sources\sfml\src\sfml\window\glcontext.cpp (159): LD36.exe!`anonymous namespace'::getInternalContext() + 0x7 bytes
    d:\sfml-release\_sources\sfml\src\sfml\window\glcontext.cpp (334): LD36.exe!sf::priv::GlContext::setActive() + 0x7 bytes
    d:\sfml-release\_sources\sfml\src\sfml\window\glcontext.cpp (189): LD36.exe!sf::priv::GlContext::globalInit()
    d:\sfml-release\_sources\sfml\src\sfml\window\glresource.cpp (56): LD36.exe!sf::GlResource::GlResource()
    d:\sfml-release\_sources\sfml\src\sfml\window\window.cpp (49): LD36.exe!sf::Window::Window() + 0x38 bytes
    d:\sfml-release\_sources\sfml\src\sfml\graphics\renderwindow.cpp (36): LD36.exe!sf::RenderWindow::RenderWindow() + 0x35 bytes
    c:\users\mace\documents\github\get-dat-boaty-post-ld36-\ld36\ld36\sattest.cpp (341): LD36.exe!main() + 0xB bytes
    f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (64): LD36.exe!invoke_main() + 0x1B bytes
    f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (253): LD36.exe!__scrt_common_main_seh() + 0x5 bytes
    f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (296): LD36.exe!__scrt_common_main()
    f:\dd\vctools\crt\vcstartup\src\startup\exe_main.cpp (17): LD36.exe!mainCRTStartup()
    KERNEL32.DLL!BaseThreadInitThunk() + 0x24 bytes
    ntdll.dll!__RtlUserThreadStart() + 0x2F bytes
    ntdll.dll!_RtlUserThreadStart() + 0x1B bytes
  Data:
    CD CD CD CD    98 DA F9 02                                   췍췍☐˹....


Visual Leak Detector detected 3 memory leaks (220 bytes).
Largest number used: 4436 bytes.
Total allocations: 7516 bytes.
Visual Leak Detector is now exiting.
The program '[11576] LD36.exe' has exited with code 0 (0x0).

I literally just have a file with those bits of code. My 2.3.2 works with no leaks, but anytime I use 2.4.0 I get this issue.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11004
    • View Profile
    • development blog
    • Email
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/


eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11004
    • View Profile
    • development blog
    • Email
AW: Memory Leak relating to RenderWindow & RenderTexture from 2.4.0
« Reply #3 on: October 09, 2016, 12:31:00 am »
If you use the 2.4.x or master branch you should see less memory leaks.

Also keep in mind that it's rather common that OpenGL drivers leak. So not all leaks you see might come from SFML.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/