Using VS debug heap (https://msdn.microsoft.com/en-us/library/974tc9t1.aspx#BKMK_Check_for_heap_integrity_and_memory_leaks) on the tutorial program, I get memory leaks in SFML master that do not occur in version 2.3.2.
The code is copied verbatim from the tutorial (http://www.sfml-dev.org/tutorials/2.3/start-vc.php), with the addition of
#include <crtdbg.h>
and
::_CrtSetDbgFlag(::_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
as the first line of main().
I use Windows 32 bit, VS 2012 Express, SFML & CRT statically-linked (and of course, run Debug version for the test). These leaks do not appear to accumulate over time (at least not in my project), but since they're new you may be interested in them.
Detected memory leaks!
Dumping objects ->
{95} normal block at 0x03A8CE90, 48 bytes long.
Data: < CK > 20 43 4B 01 00 00 00 00 00 00 00 00 00 00 00 00
{94} normal block at 0x03A15B78, 8 bytes long.
Data: < > CD CD CD CD 90 CE A8 03
{93} normal block at 0x00522020, 48 bytes long.
Data: < CK > 20 43 4B 01 18 00 00 00 00 00 00 00 00 00 00 00
Object dump complete.
Tracing the allocations with _CrtSetBreakAlloc():
- new ContextType(NULL) in GlContext::globalInit()
- new sf::Context in getInternalContext()
- new ContextType(sharedContext) in GlContext::create()
EDIT: the leaks were "fixed" by manually calling sf::priv::GlContext::globalCleanup() at the end of main().
::_CrtSetDbgFlag(::_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
as the first line of main().
SFML has certain global states, so if you start tracking memory allocations only after main() is called, you're already missing things.
To be honest if you stick to modern C++ with RAII memory leak tracking will become obsolete pretty quickly.
Well, I've looked into it further. Fixed everything by adding the following at the end of main():
#ifdef _DEBUG
// fix the following SFML memory leaks:
// - new ContextType(NULL) in GlContext::globalInit()
// - new sf::Context in getInternalContext()
// - new ContextType(sharedContext) in GlContext::create()
sf::priv::GlContext::globalCleanup();
#endif
As I link statically, no change to SFML was needed, only the following declaration before main():
namespace sf { namespace priv { class GlContext { public: static void globalCleanup(); }; } }
I could've done it earlier if I hadn't relied on the following SFML version for a fix. Will learn next time.