SFML community forums

Help => General => Topic started by: Chivos on April 16, 2013, 01:54:45 am

Title: Valgrind with SFML
Post by: Chivos on April 16, 2013, 01:54:45 am
I have been working on getting Valgrind to work all day. Valgrind works well when I do not include any SFML headers, but the second I include <SFML/Graphics.hpp>, I get something like 2.6million errors. Obviously there is no way that this is being caused by SFML lol, but I am not sure what to do about it. Does anyone know why this might be happening? Any advice or help would be greatly appreciated! ;)
Title: Re: Valgrind with SFML
Post by: The Terminator on April 16, 2013, 02:34:33 am
What version of SFML are you using?
Did you compile with Cmake?
Did you link the correct libraries?
What are your errors?

So many questions, not very many answers  ;)
Title: Re: Valgrind with SFML
Post by: Chivos on April 16, 2013, 02:36:56 am
lol, i'm still using 1.6.. I know.. I know heheh ;)

I DL'd with the repository

I am pretty sure I am linked the correct libraries. I do not think it would compile if not. When I compile it to run valgrind on it, I use this.

g++  main.cpp /usr/lib/libsfml-window.so.1.6 /usr/lib/libsfml-graphics.so.1.6 -o test

to run:

valgrind --leak-check=full  ./test

main.cpp includes <SFML/Graphics.hpp> and has an int main(){return 0;}

As far as the errors, there are 2.6million so I assume they don't mean much as it is something else I am doing wrong heh.
Title: Re: Valgrind with SFML
Post by: The Terminator on April 16, 2013, 03:47:05 am
You say that you're only using graphics and window, but both depend on system. Try including libsfml-system when you run your code.
Title: Re: Valgrind with SFML
Post by: Chivos on April 16, 2013, 07:34:14 am
I am having the exact same problem. I have also switched to 2.0 to see if that would help. The number of errors is still ridiculously high. I have to crash out, but I think tomorrow I will just try to reinstall Valgrind or something. If anyone has any ideas, please feel free to chime in, I am at a lose! :(


Just checked again, Valgrind still works as long as nothing SFML touches it heh. ALL day because I wanted to see if I had any memory leaks lol ;)
Title: Re: Valgrind with SFML
Post by: binary1248 on April 16, 2013, 04:22:19 pm
SFML makes use of numerous static variables that are instanciated at application startup whether you use SFML or not. Many of these also have to do with OpenGL context management which might look like a leak if you have "unhealthy" graphics drivers. Unless you have a reference to a specific line of code in the SFML codebase (yes, Valgrind shows you the line when possible) that really shows that memory is allocated that might not be freed, everything else is part of the operating system and we don't go there.
Title: Re: Valgrind with SFML
Post by: Chivos on April 16, 2013, 05:08:05 pm
Thank you very much binary1248!!! Updated graphics drivers and it solved my problem!! ;)