1
Graphics / [SFML2]sf::Font memory leak
« on: January 10, 2010, 04:09:47 pm »
I found that using function LoadFromFile for sf::Font generates a memory leak (actually a 64 memory leaks for valid loading and 38 when file is not present via Visual Leak Detector 1.9b).
Call Stack:
Other leaks have info only about
So using debugger i discovered that in Cleanup function code responsible for cleaning looks that:
but myRefcount is set by default constructor to NULL and never set to any value (and in fact before loading from file CLeanup sets it to NULL again and leaves it that way) and cleaning functions are never called.
So a fast fix in LoadFromFile function and LoadFromMemory
makes memory leaks no more
Call Stack:
Code: [Select]
0x00A3F50A (File and line number not available): glPushAttrib
0x00A4AD11 (File and line number not available): FT_Done_Memory
0x00A77E81 (File and line number not available): TT_RunIns
0x00A30732 (File and line number not available): FT_Load_Char
0x00A32D94 (File and line number not available): FT_Open_Face
0x00A33059 (File and line number not available): FT_New_Face
c:\sfml2\src\sfml\graphics\font.cpp (93): sf::Font::LoadFromFile
Other leaks have info only about
Code: [Select]
0x00A3F50A (File and line number not available): glPushAttrib
So using debugger i discovered that in Cleanup function code responsible for cleaning looks that:
Code: [Select]
if(myRefcount)
{
//cleaning;
}
but myRefcount is set by default constructor to NULL and never set to any value (and in fact before loading from file CLeanup sets it to NULL again and leaves it that way) and cleaning functions are never called.
So a fast fix in LoadFromFile function and LoadFromMemory
Code: [Select]
// Cleanup the previous resources
Cleanup();
myRefCount = new int;
*myRefCount = 1;
makes memory leaks no more