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

Author Topic: [Solved] SFML 1.3 Leaking Memory Under MinGW  (Read 2477 times)

0 Members and 1 Guest are viewing this topic.

Wizzard

  • Full Member
  • ***
  • Posts: 213
    • View Profile
[Solved] SFML 1.3 Leaking Memory Under MinGW
« 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

Wizzard

  • Full Member
  • ***
  • Posts: 213
    • View Profile
[Solved] SFML 1.3 Leaking Memory Under MinGW
« Reply #1 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 possibly be the problem?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
[Solved] SFML 1.3 Leaking Memory Under MinGW
« Reply #2 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.
Laurent Gomila - SFML developer

Wizzard

  • Full Member
  • ***
  • Posts: 213
    • View Profile
[Solved] SFML 1.3 Leaking Memory Under MinGW
« Reply #3 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
[Solved] SFML 1.3 Leaking Memory Under MinGW
« Reply #4 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.
Laurent Gomila - SFML developer

 

anything