SFML community forums
Help => Window => Topic started by: Wizzard on June 24, 2008, 03:06:47 am
-
Nvwa's memory leak detector is detecting a memory leak of 176 bytes when I create a sf::Window instance under MinGW using the following code:
#include <SFML/Window.hpp>
int main() {
sf::Event event;
sf::Window window(sf::VideoMode(640, 480), "Window", sf::Style::Close);
for (;;) {
while (window.GetEvent(event)) {
if (event.Type == sf::Event::Closed)
return 0;
}
window.Display();
}
}
Should I be concerned about this? SFML 1.2 never reported any memory leaks. I am using Windows XP with SP 2 and here's the commands I used to build the code:
mingw32-g++.exe -g -c test.cpp -o test.o
mingw32-g++.exe -g -c debug_new.cpp -o debug_new.o
mingw32-g++.exe -o tile-d.exe main.o debug_new.o -lsfml-window-s-d -lsfml-system-s-d
-
Where is the variable sf::Window::ourDummyWindow deleted?
This may be the source of the memory leak.
EDIT: Maybe not, it seems the memory leak happens even when I do the following code:
#include <SFML/Graphics.hpp>
int main() {
sf::Image image;
}
Could this (http://www.sfml-dev.org/forum/viewtopic.php?t=399) possibly be the problem?
-
Could this possibly be the problem?
Yes ;)
So don't worry about it, it's a controlled leak which will never be bigger than 176 bytes. And of course your OS will free the memory on exit.
-
That's good news. I was just worried about this because it didn't happen in SFML 1.2.
-
I know, in 1.2 this variable was created and destroyed in global scope. This may sound good, but it caused problems especially when using SFML in a DLL.
Now, this global is created on demand on destroyed by the OS.