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

Author Topic: Possible memory leak  (Read 1632 times)

0 Members and 1 Guest are viewing this topic.

roccio

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
    • Email
Possible memory leak
« on: October 12, 2017, 04:06:22 pm »
Hello, I was trying to play with many windows for my application, and I noticed one strange thing (I see it using default window manager).

When I create a new window the memory goes up.
When I delete the window the memory goes down, but just a little, so that if I continue to create windows the memory used will grow.
I noticed that this only happes if I use antialias in context settings, so maybe it's a driver issue.

Here is a little code to reproduce.

Code: [Select]
#include <SFML/Graphics.hpp>
#include <vector>

int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);

std::vector<sf::RenderWindow*> windows;

while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
else if (event.type == sf::Event::KeyPressed)
{
if (event.key.code == sf::Keyboard::A)
{
sf::ContextSettings settings;
settings.antialiasingLevel = 8;

sf::RenderWindow* wnd = new sf::RenderWindow();
wnd->create({ 800, 800 }, "2", sf::Style::Default, settings);
windows.push_back(wnd);
}
if (event.key.code == sf::Keyboard::D)
{
for (auto wnd : windows)
wnd->close();
// delete wnd;

windows.clear();
}
}
}

window.clear();
window.draw(shape);
window.display();

for (auto wnd : windows)
{
wnd->clear();
wnd->display();
}
}

return 0;
}

 

anything