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

Author Topic: SfRenderWindow leak  (Read 1429 times)

0 Members and 1 Guest are viewing this topic.

Jozan

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
SfRenderWindow leak
« on: January 11, 2021, 05:04:36 pm »
Hi, this might a bit of a classic one but when using valgrind on my small CSFML program I get 3 fat leaks at exit time despite using sfRenderWindow_destroy(). sfRenderWindow_close() does not change anything and so does free().

It says that leaks come from libsfml-window.so which I don't understand because I link with -lcsfml-window and not -lsfml-window since my whole program is in C.

Maybe there's something I just don't get with CSFML because some sfThreads send some leaks as well despite using sfThread_destroy().

Here is my valgrind output:


==22009== 1,440 bytes in 9 blocks are still reachable in loss record 219 of 234
==22009==    at 0x4A4C86E: malloc (vg_replace_malloc.c:312)
==22009==    by 0x54995C1: hid_init (in /usr/lib/libusbhid.so.4)
==22009==    by 0x514B608: ? ? ? (in /usr/local/lib/libsfml-window.so.2.5.1)
==22009==    by 0x5139C87: ? ? ? (in /usr/local/lib/libsfml-window.so.2.5.1)
==22009==    by 0x5139449: ? ? ? (in /usr/local/lib/libsfml-window.so.2.5.1)
==22009==    by 0x513C366: ? ? ? (in /usr/local/lib/libsfml-window.so.2.5.1)
==22009==    by 0x5142E07: ? ? ? (in /usr/local/lib/libsfml-window.so.2.5.1)
==22009==    by 0x513C172: ? ? ? (in /usr/local/lib/libsfml-window.so.2.5.1)
==22009==    by 0x513B7F6: sf::Window::create(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&) (in /usr/local/lib/libsfml-window.so.2.5.1)
==22009==    by 0x4C9F31F: sfRenderWindow_create (in /usr/local/lib/libcsfml-graphics.so.2.5)
==22009==    by 0x20EF92: e_create_win (e_engine.c:87)
==22009==    by 0x208692: main (c_dergods.c:80)
==22009==
==22009== 26,771 bytes in 1,701 blocks are still reachable in loss record 233 of 234
==22009==    at 0x4A4C86E: malloc (vg_replace_malloc.c:312)
==22009==    by 0x4DA957F: strdup (in /lib/libc.so.7)
==22009==    by 0x549948B: hid_init (in /usr/lib/libusbhid.so.4)
==22009==    by 0x514B608: ? ? ? (in /usr/local/lib/libsfml-window.so.2.5.1)
==22009==    by 0x5139C87: ? ? ? (in /usr/local/lib/libsfml-window.so.2.5.1)
==22009==    by 0x5139449: ? ? ? (in /usr/local/lib/libsfml-window.so.2.5.1)
==22009==    by 0x513C366: ? ? ? (in /usr/local/lib/libsfml-window.so.2.5.1)
==22009==    by 0x5142E07: ? ? ? (in /usr/local/lib/libsfml-window.so.2.5.1)
==22009==    by 0x513C172: ? ? ? (in /usr/local/lib/libsfml-window.so.2.5.1)
==22009==    by 0x513B7F6: sf::Window::create(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&) (in /usr/local/lib/libsfml-window.so.2.5.1)
==22009==    by 0x4C9F31F: sfRenderWindow_create (in /usr/local/lib/libcsfml-graphics.so.2.5)
==22009==    by 0x20EF92: e_create_win (e_engine.c:87)
==22009==
==22009== 27,680 bytes in 19 blocks are still reachable in loss record 234 of 234
==22009==    at 0x4A4E244: realloc (vg_replace_malloc.c:980)
==22009==    by 0x5499546: hid_init (in /usr/lib/libusbhid.so.4)
==22009==    by 0x514B608: ? ? ? (in /usr/local/lib/libsfml-window.so.2.5.1)
==22009==    by 0x5139C87: ? ? ? (in /usr/local/lib/libsfml-window.so.2.5.1)
==22009==    by 0x5139449: ? ? ? (in /usr/local/lib/libsfml-window.so.2.5.1)
==22009==    by 0x513C366: ? ? ? (in /usr/local/lib/libsfml-window.so.2.5.1)
==22009==    by 0x5142E07: ? ? ? (in /usr/local/lib/libsfml-window.so.2.5.1)
==22009==    by 0x513C172: ? ? ? (in /usr/local/lib/libsfml-window.so.2.5.1)
==22009==    by 0x513B7F6: sf::Window::create(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&) (in /usr/local/lib/libsfml-window.so.2.5.1)
==22009==    by 0x4C9F31F: sfRenderWindow_create (in /usr/local/lib/libcsfml-graphics.so.2.5)
==22009==    by 0x20EF92: e_create_win (e_engine.c:87)
==22009==    by 0x208692: main (c_dergods.c:80)


Is there a way I don't know to cleanly exit my program or should I just ignore these?

(btw sorry if this is in the wrong forum but sfRenderWindow is part of the graphics lib not the window one so I don't know)
« Last Edit: January 11, 2021, 05:07:13 pm by Jozan »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: SfRenderWindow leak
« Reply #1 on: January 30, 2021, 11:49:39 am »
CSFML is just a C API that underneath calls the C++ SFML library.

As you can see the leak actually comes from libusbhid.so so it's likely a driver issue or just a false-positive.
If you really want to figure it out, use a debug build and drill down further.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/