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

Author Topic: sv::VideoMode memory leak  (Read 2652 times)

0 Members and 1 Guest are viewing this topic.

tntexplosivesltd

  • Full Member
  • ***
  • Posts: 163
    • View Profile
sv::VideoMode memory leak
« on: January 28, 2011, 05:12:22 am »
I am using SFML 1.6 under Arch Linux, and I came across a small problem. When running my code through Valgrind, it says:
"28 bytes in block 1 definitely lost"
or something like that. Here is the offending line:
Code: [Select]

sf::VideoMode best_mode = sf::VideoMode::GetMode(0);

It has the same leak if I use a constructor list:
Code: [Select]

sf::VideoMode best_mode;
void Initialise() : best_mode(sf::VideoMode::GetMode(0))
{
  ...
}

Is this an error in SFML, or am I doing something wrong?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sv::VideoMode memory leak
« Reply #1 on: January 28, 2011, 07:36:41 am »
There was a memory leak in this function, maybe it was not fixed in SFML 1.6, I don't really remember.

Anyway, you're not doing anything wrong.
Laurent Gomila - SFML developer

tntexplosivesltd

  • Full Member
  • ***
  • Posts: 163
    • View Profile
sv::VideoMode memory leak
« Reply #2 on: January 28, 2011, 09:08:39 am »
Cool, that's good to hear :wink:
Will this be fixed in SFML 2?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sv::VideoMode memory leak
« Reply #3 on: January 28, 2011, 09:17:25 am »
It's already fixed.
Laurent Gomila - SFML developer

tntexplosivesltd

  • Full Member
  • ***
  • Posts: 163
    • View Profile
sv::VideoMode memory leak
« Reply #4 on: January 28, 2011, 09:19:14 am »
Awesome. What actually caused the leak?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sv::VideoMode memory leak
« Reply #5 on: January 28, 2011, 09:32:33 am »
I forgot to call XFree on a resource.
Laurent Gomila - SFML developer