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

Author Topic: Questions about memory leaks (Valgrind)  (Read 1417 times)

0 Members and 1 Guest are viewing this topic.

Nellousan

  • Newbie
  • *
  • Posts: 1
    • View Profile
Questions about memory leaks (Valgrind)
« on: December 29, 2020, 04:10:20 pm »
(it's my first time posting here please tell me if i break any rules or do anything wrong)

Hello,

i have a few questions about memory leaks on my project.
i'm on Fedora 29 and use SFML 2.5.1 (not entirely sure, idk how to check but it's mentioned on the errors below).

here is the leak summary, i use valgrind:

==31952== LEAK SUMMARY:
==31952==    definitely lost: 3,728 bytes in 15 blocks
==31952==    indirectly lost: 920 bytes in 10 blocks
==31952==      possibly lost: 69,191,766 bytes in 9,228 blocks
==31952==    still reachable: 247,786 bytes in 1,287 blocks
==31952==         suppressed: 0 bytes in 0 blocks
 

I'm almost sure that these leaks doesn't come from forgetting to delete objects or free mallocs, i might have forgotten some, but definitely not worth 69MB of memory.

since there is thousands of errors i won't show them all in here but most of these errors looks like this:
==31952== 17,580,048 bytes in 1 blocks are possibly lost in loss record 2,038 of 2,039
==31952==    at 0x483880B: malloc (vg_replace_malloc.c:309)
==31952==    by 0x5B75929: ??? (in /usr/lib64/dri/i965_dri.so)
==31952==    by 0x59A3877: ??? (in /usr/lib64/dri/i965_dri.so)
==31952==    by 0x5A488E4: ??? (in /usr/lib64/dri/i965_dri.so)
==31952==    by 0x5720ED2: ???
==31952==    by 0x5708EC8: ???
==31952==    by 0x5122553: ??? (in /usr/lib64/libGLX.so.0.0.0)
==31952==    by 0x48E1267: ??? (in /usr/lib64/libsfml-window.so.2.5.1)
==31952==    by 0x48E173A: ??? (in /usr/lib64/libsfml-window.so.2.5.1)
==31952==    by 0x48D269F: ??? (in /usr/lib64/libsfml-window.so.2.5.1)
==31952==    by 0x48D5027: sf::Window::create(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&) (in /usr/lib64/libsfml-window.so.2.5.1)
==31952==    by 0x48A1ED4: sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&) (in /usr/lib64/libsfml-graphics.so.2.5.1)
 

or like this:
==31952== 145,392 bytes in 3 blocks are possibly lost in loss record 2,028 of 2,039
==31952==    at 0x483AE45: memalign (vg_replace_malloc.c:908)
==31952==    by 0x483AF47: posix_memalign (vg_replace_malloc.c:1072)
==31952==    by 0x5ABBA02: ??? (in /usr/lib64/dri/i965_dri.so)
==31952==    by 0x5B22E82: ??? (in /usr/lib64/dri/i965_dri.so)
==31952==    by 0x5B64288: ??? (in /usr/lib64/dri/i965_dri.so)
==31952==    by 0x5B5A979: ??? (in /usr/lib64/dri/i965_dri.so)
==31952==    by 0x5B59039: ??? (in /usr/lib64/dri/i965_dri.so)
==31952==    by 0x59A29D6: ??? (in /usr/lib64/dri/i965_dri.so)
==31952==    by 0x5A488E4: ??? (in /usr/lib64/dri/i965_dri.so)
==31952==    by 0x5720ED2: ???
==31952==    by 0x5708EC8: ???
==31952==    by 0x5122553: ??? (in /usr/lib64/libGLX.so.0.0.0)
 

what i deduced is that these errors don't come from me but from the graphic engine or other libs or something like this(i don't quite understand clearly how all of this works).

So my questions are:
- Is it true, can these errors comes from other lib or did i definitely do something wrong ?
- Also, most of these leaks are declared as "possibly lost", does it means that maybe the graphic engine i'm speaking of freed them but valgrind could not detect it ?
- Am i the only one encoutering these kinds of leaks ?

Also what's may be worth to mention is that no matter how long the process runs, the leaks are more or less the same size. (just to clarify that these leaks aren't generated by looping allocations or something).

There's a lot of black boxes on how sfml works that i'm starting to understand, please don't hesitate to go technical in the replies if you think it can help me understand how all of this stuff works.

Thanks a lot.
(also sorry if bad english, i hope it's perfectly understandable)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Questions about memory leaks (Valgrind)
« Reply #1 on: January 25, 2021, 09:06:03 pm »
If you search the forum you'll find a lot of similar posts.
Valgrind and other memory leak detection tools need to be used correctly and even then can show false positives.

Plus GPU drivers are also known to leak memory (or appear to do so).

Best you focus on your application and use of good coding practices (unique_ptr, no manual memory management, etc) and worry less about potential memory leaks. :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything