SFML community forums

Help => Window => Topic started by: Wizzard on June 24, 2008, 03:06:47 am

Title: [Solved] SFML 1.3 Leaking Memory Under MinGW
Post 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:

Code: [Select]
#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:

Code: [Select]
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
Title: [Solved] SFML 1.3 Leaking Memory Under MinGW
Post by: Wizzard on June 27, 2008, 03:34:32 am
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:

Code: [Select]
#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?
Title: [Solved] SFML 1.3 Leaking Memory Under MinGW
Post by: Laurent on June 27, 2008, 04:08:30 am
Quote
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.
Title: [Solved] SFML 1.3 Leaking Memory Under MinGW
Post by: Wizzard on June 27, 2008, 07:04:37 am
That's good news. I was just worried about this because it didn't happen in SFML 1.2.
Title: [Solved] SFML 1.3 Leaking Memory Under MinGW
Post by: Laurent on June 27, 2008, 07:35:43 am
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.