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

Author Topic: SFML 2.0 & Memory Leaks  (Read 3337 times)

0 Members and 1 Guest are viewing this topic.

CBenni::O

  • Newbie
  • *
  • Posts: 48
    • View Profile
SFML 2.0 & Memory Leaks
« on: March 12, 2010, 10:37:16 pm »
Hy,

I was playing a bit with the vld (Visual Leak Detector) and SFML, and this piece of Code (taken from the example Code) Throws 83 Memory Leaks!

Code: [Select]
#include <vld.h>
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>

int main()
{
// Create the main window
sf::RenderWindow App(sf::VideoMode(800, 600), "SFML window");
 
// Load a sprite to display
sf::Image Image;
if (!Image.LoadFromFile("cute_image.jpg"))
return EXIT_FAILURE;
sf::Sprite Sprite(Image);
 
// Create a graphical string to display
sf::Font Arial;
if (!Arial.LoadFromFile("arial.ttf"))
return EXIT_FAILURE;
sf::Text Text("Hello SFML", Arial, 50);
 
// Load a music to play
sf::Music Music;
if (!Music.OpenFromFile("nice_music.ogg"))
return EXIT_FAILURE;

// Play the music
Music.Play();
 
// Start the game loop
while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();
}
 
// Clear screen
App.Clear();
 
// Draw the sprite
App.Draw(Sprite);
 
// Draw the string
App.Draw(Text);
 
// Update the window
App.Display();
}
 
return EXIT_SUCCESS;

}


Whats the matter? Most of them appear to be inside of sf::Drawable...
bye, CBenni::O
42!
Metal will never die!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: SFML 2.0 & Memory Leaks
« Reply #1 on: March 12, 2010, 11:29:47 pm »
Quote from: "CBenni::O"
I was playing a bit with the vld (Visual Leak Detector) and SFML, and this piece of Code (taken from the example Code) Throws 83 Memory Leaks!

[...]

Whats the matter?
It's highly probable that you applied the leak detector tool in a wrong way. You should get used to it, before you claim SFML. ;)

I don't know what's exactly the problem. Apparently, VLD doesn't recognize all deallocations, for any reason. We've already had a similar issue, see here.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

CBenni::O

  • Newbie
  • *
  • Posts: 48
    • View Profile
Re: SFML 2.0 & Memory Leaks
« Reply #2 on: March 12, 2010, 11:49:46 pm »
Quote from: "Nexus"
Quote from: "CBenni::O"
I was playing a bit with the vld (Visual Leak Detector) and SFML, and this piece of Code (taken from the example Code) Throws 83 Memory Leaks!

[...]

Whats the matter?
It's highly probable that you applied the leak detector tool in a wrong way. You should get used to it, before you claim SFML. ;)


What have I done wrong, then? In the description of vld it only says that you simply have to add #include <vld.h> in the beginning of the file...

And usually it works :?

I'll try some more...

bye, CBenni::O

EDIT: If I take out everything which is related to sf::Text (creating and Drawing the String), there are no Memory-Leaks recorded
42!
Metal will never die!

 

anything