In searching for a possible memory leak I have encountered and isolated, I came across this forum topic:
http://en.sfml-dev.org/forums/index.php?topic=10309.0It was said that the memory leak involving the setActive(bool) function was because SFML cannot tell if a std::thread were to end, thus resulting in the memory still being allocated.
I am creating a sf::Thread that takes the handle of handle of the openGL context by called setActive(true), then releasing it with setActive(false), and finally ending.
Every time this thread gets called, it results in ~5.68MB increase in private memory, and ~0.2MB increase in virtual memory on the process.
Is this a relating problem? If so, then why doesn't SFML free the memory when the thread ends? SFML should be able to determine when it does.
Copy and paste-able example:
void secondMain(sf::RenderWindow* renderWindow){
renderWindow->setActive(true);
renderWindow->setActive(false);
}
int main(int argc, char **argv) {
sf::RenderWindow renderWindow;
renderWindow.create(sf::VideoMode(800, 600), "Text");
sf::Thread thread(secondMain, &renderWindow);
renderWindow.setActive(false);
while(renderWindow.isOpen()) {
sf::Event evt;
while(renderWindow.pollEvent(evt)) {
switch(evt.type) {
case sf::Event::KeyPressed: //press a key to see the memory increase
thread.launch();
thread.wait();
break;
case sf::Event::Closed:
renderWindow.close();
break;
default:
break;
}
}
}
}
I am using the latest GitHub version of SFML, running on Windows 8.1. Compiling with MinGW-64 (GCC 4.9.2 x86_64-posix-sjlj-rev0). If any further information is required, please notify me.