Hi.
I tried to use this in my project, however after debuging I found this module is generating serious memory leaks. Here's what _CrtDumpMemoryLeaks showed:
Code: Select all
Detected memory leaks!
Dumping objects ->
{401} normal block at 0x01198158, 2496 bytes long.
Data: < M > D0 8C 18 01 01 00 00 00 4D 00 00 00 00 00 00 00
{400} normal block at 0x01198110, 12 bytes long.
Data: < > 00 00 00 00 00 00 00 00 88 80 19 01
{399} normal block at 0x01198088, 76 bytes long.
Data: < > 88 D5 18 01 00 00 00 00 00 00 00 00 00 00 00 00
{398} normal block at 0x01197FF0, 88 bytes long.
Data: < > D0 8C 18 01 00 00 00 00 00 00 00 00 00 00 00 00
{397} normal block at 0x01197F88, 40 bytes long.
Data: < > F0 7F 19 01 00 00 00 00 00 00 00 00 00 00 00 00
{396} normal block at 0x01197EA0, 172 bytes long.
Data: < > 20 8D 18 01 88 D5 18 01 00 00 00 00 00 00 00 00
{395} normal block at 0x003DF668, 12 bytes long.
Data: < > 00 00 00 00 00 00 00 00 88 D5 18 01
{394} normal block at 0x01197E50, 16 bytes long.
Data: < = = = = > 88 F5 3D 00 18 F6 3D 00 B0 F6 3D 00 A8 FF 3D 00
{393} normal block at 0x003DFFA8, 20 bytes long.
Data: < BODA 8 L > 88 D5 18 01 42 4F 44 41 07 00 00 00 38 0C 4C 00
{392} normal block at 0x01197E00, 18 bytes long.
Data: <MinionPro-Regula> 4D 69 6E 69 6F 6E 50 72 6F 2D 52 65 67 75 6C 61
{390} normal block at 0x01197438, 2444 bytes long.
Data: < > 00 00 01 00 02 00 03 00 04 00 05 00 06 00 07 00
{389} normal block at 0x01196EA0, 1372 bytes long.
Data: <P H > 50 FF 18 01 B7 FF 18 01 DF FF 18 01 48 00 19 01
{387} normal block at 0x01195B48, 4892 bytes long.
Data: < A D > 01 00 00 00 41 00 00 00 44 00 00 00 9E 00 00 00
{386} normal block at 0x011955B0, 1372 bytes long.
Data: < . / v/ / > D0 2E 19 01 16 2F 19 01 76 2F 19 01 96 2F 19 01
{385} normal block at 0x01192ED0, 9891 bytes long.
Data: < k 5 ` > F7 6B F8 00 15 F7 35 CD 0A DA 60 1D E0 85 93 83
{383} normal block at 0x01192938, 1372 bytes long.
Data: < G > 01 00 00 00 47 00 00 00 A7 00 00 00 C7 00 00 00
{380} normal block at 0x0118FF50, 10665 bytes long.
Data: < m ! 1 > F7 CC 16 92 97 05 6D BD FB 02 F7 21 F7 31 1A F7
{378} normal block at 0x0118F9B8, 1372 bytes long.
Data: < h > 01 00 00 00 68 00 00 00 90 00 00 00 F9 00 00 00
{376} normal block at 0x0118EC38, 3396 bytes long.
Data: < > 01 00 00 00 0C 00 00 00 12 00 00 00 19 00 00 00
{374} normal block at 0x003DFF60, 8 bytes long.
Data: < 3 > 01 00 00 00 33 00 00 00
{372} normal block at 0x003DFF18, 8 bytes long.
Data: < > 01 00 00 00 12 00 00 00
{370} normal block at 0x003DF700, 2008 bytes long.
Data: < > C8 D4 18 01 D0 8C 18 01 01 00 00 00 C6 04 00 00
{368} normal block at 0x003DF6B0, 20 bytes long.
Data: < cinu `cK > 88 D5 18 01 63 69 6E 75 03 00 01 00 60 63 4B 00
{366} normal block at 0x003DF618, 20 bytes long.
Data: < nmra cK > 88 D5 18 01 6E 6D 72 61 01 00 00 00 80 63 4B 00
{364} normal block at 0x003DF588, 20 bytes long.
Data: < cinu `cK > 88 D5 18 01 63 69 6E 75 00 00 03 00 60 63 4B 00
{363} normal block at 0x003DF540, 8 bytes long.
Data: <Regular > 52 65 67 75 6C 61 72 00
{362} normal block at 0x003DF4F0, 14 bytes long.
Data: < R e g u l a r> 00 52 00 65 00 67 00 75 00 6C 00 61 00 72
{361} normal block at 0x003DF4A8, 11 bytes long.
Data: <Minion Pro > 4D 69 6E 69 6F 6E 20 50 72 6F 00
{360} normal block at 0x003DF458, 20 bytes long.
Data: < M i n i o n P> 00 4D 00 69 00 6E 00 69 00 6F 00 6E 00 20 00 50
{355} normal block at 0x003DE100, 4888 bytes long.
Data: < T D , > F4 01 00 00 FB 00 00 00 18 01 54 00 44 01 2C 00
{351} normal block at 0x0118EA40, 440 bytes long.
Data: < > 01 00 00 00 00 00 00 00 84 00 00 00 9E 02 00 00
{349} normal block at 0x003DD570, 2894 bytes long.
Data: < > 00 00 00 03 00 00 00 03 00 00 02 14 00 01 00 00
{345} normal block at 0x0118E940, 192 bytes long.
Data: < FFC g T > 20 46 46 43 BC 67 96 10 54 12 00 00 0F 91 01 00
{331} normal block at 0x0118D890, 52 bytes long.
Data: < > 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00
{330} normal block at 0x0118D588, 712 bytes long.
Data: < > 01 00 00 00 00 00 00 00 19 02 00 00 00 00 00 00
{306} normal block at 0x0118D4C8, 40 bytes long.
Data: < = n p 0 > A8 FF 3D 00 D8 96 02 00 6E 12 00 00 70 AC 30 10
{305} normal block at 0x0118D460, 40 bytes long.
Data: < [K > 20 5B 4B 00 20 8D 18 01 D0 8C 18 01 00 00 00 00
{304} normal block at 0x0118D3C8, 88 bytes long.
Data: < > D0 8C 18 01 00 00 00 00 00 00 00 00 00 00 00 00
{303} normal block at 0x003DD438, 40 bytes long.
Data: < \K > A0 5C 4B 00 20 8D 18 01 D0 8C 18 01 00 00 00 00
{302} normal block at 0x003DD3A0, 88 bytes long.
Data: < > D0 8C 18 01 00 00 00 00 00 00 00 00 00 00 00 00
{301} normal block at 0x003DD330, 48 bytes long.
Data: < _K > E0 5F 4B 00 20 8D 18 01 D0 8C 18 01 00 00 00 00
{300} normal block at 0x0118CE60, 1324 bytes long.
Data: < > 20 8E 18 01 00 04 00 00 00 00 00 00 00 00 00 00
{299} normal block at 0x003DD2E8, 12 bytes long.
Data: < = ` = > B0 CC 3D 00 00 00 00 00 60 D2 3D 00
{298} normal block at 0x003DD260, 72 bytes long.
Data: < aK > 84 61 4B 00 20 8D 18 01 D0 8C 18 01 00 00 00 00
{297} normal block at 0x003DCCF8, 1324 bytes long.
Data: < > 20 8E 18 01 00 04 00 00 00 00 00 00 00 00 00 00
{296} normal block at 0x003DCCB0, 12 bytes long.
Data: <x = = ( = > 78 C6 3D 00 E8 D2 3D 00 28 CC 3D 00
{295} normal block at 0x003DCC28, 72 bytes long.
Data: <HaK > 48 61 4B 00 20 8D 18 01 D0 8C 18 01 00 00 00 00
{294} normal block at 0x003DC6C0, 1324 bytes long.
Data: < > 20 8E 18 01 00 04 00 00 00 00 00 00 00 00 00 00
{293} normal block at 0x003DC678, 12 bytes long.
Data: <h = = > 68 88 18 01 B0 CC 3D 00 F0 C5 3D 00
{292} normal block at 0x003DC5F0, 72 bytes long.
Data: < aK > 0C 61 4B 00 20 8D 18 01 D0 8C 18 01 00 00 00 00
{291} normal block at 0x003DC5A0, 20 bytes long.
Data: < dK > E4 64 4B 00 20 8D 18 01 D0 8C 18 01 00 00 00 00
{290} normal block at 0x003DBD58, 2060 bytes long.
Data: < > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
{289} normal block at 0x01188868, 12 bytes long.
Data: < x = = > 00 00 00 00 78 C6 3D 00 D0 BC 3D 00
{288} normal block at 0x003DBCD0, 72 bytes long.
Data: < fK > 80 66 4B 00 20 8D 18 01 D0 8C 18 01 00 00 00 00
{287} normal block at 0x003DBBE0, 176 bytes long.
Data: < gK > 20 67 4B 00 20 8D 18 01 D0 8C 18 01 00 00 00 00
{286} normal block at 0x003DBB90, 20 bytes long.
Data: <L K > 4C D2 4B 00 20 8D 18 01 D0 8C 18 01 00 00 00 00
{285} normal block at 0x003DBB40, 20 bytes long.
Data: <H K > 48 E9 4B 00 20 8D 18 01 D0 8C 18 01 00 00 00 00
{284} normal block at 0x003DBAD8, 40 bytes long.
Data: < K > A8 F0 4B 00 20 8D 18 01 D0 8C 18 01 00 00 00 00
{283} normal block at 0x003DBA70, 40 bytes long.
Data: < K > D8 F4 4B 00 20 8D 18 01 D0 8C 18 01 00 00 00 00
{282} normal block at 0x003DB9D8, 88 bytes long.
Data: < > D0 8C 18 01 00 00 00 00 00 00 00 00 00 00 00 00
{281} normal block at 0x003DB970, 40 bytes long.
Data: < K > 18 FC 4B 00 20 8D 18 01 D0 8C 18 01 00 00 00 00
{280} normal block at 0x003DB8D8, 88 bytes long.
Data: < > D0 8C 18 01 00 00 00 00 00 00 00 00 00 00 00 00
{279} normal block at 0x003DB870, 44 bytes long.
Data: <@ K > 40 FE 4B 00 20 8D 18 01 D0 8C 18 01 00 00 00 00
{278} normal block at 0x003DB7D8, 88 bytes long.
Data: < > D0 8C 18 01 00 00 00 00 00 00 00 00 00 00 00 00
{277} normal block at 0x003DB770, 40 bytes long.
Data: < L > B8 14 4C 00 20 8D 18 01 D0 8C 18 01 00 00 00 00
{276} normal block at 0x003DB6D8, 88 bytes long.
Data: < > D0 8C 18 01 00 00 00 00 00 00 00 00 00 00 00 00
{275} normal block at 0x003DB650, 76 bytes long.
Data: < L > 90 16 4C 00 20 8D 18 01 D0 8C 18 01 00 00 00 00
{274} normal block at 0x003DB5B8, 88 bytes long.
Data: < > D0 8C 18 01 00 00 00 00 00 00 00 00 00 00 00 00
{273} normal block at 0x003DB528, 80 bytes long.
Data: < > D0 8C 18 01 00 00 00 00 00 00 00 00 00 00 00 00
{272} normal block at 0x003DB498, 80 bytes long.
Data: < > D0 8C 18 01 00 00 00 00 00 00 00 00 00 00 00 00
{271} normal block at 0x003DB440, 24 bytes long.
Data: < L > 90 1B 4C 00 20 8D 18 01 D0 8C 18 01 00 00 00 00
{270} normal block at 0x01188E20, 16384 bytes long.
Data: < > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
{269} normal block at 0x01188D20, 196 bytes long.
Data: < > D0 8C 18 01 00 00 00 00 00 00 00 00 02 00 00 00
{268} normal block at 0x01188CD0, 16 bytes long.
Data: < D p D 0 D > 00 00 00 00 00 F6 44 00 70 F6 44 00 30 F6 44 00
Object dump complete.
I went into details and removed those leaks by makinf following fixes:
1. In
CGUITTGlyph::cache(u32 idx)
The object 'img' is allocated twice, but not deleted. So I added bolded lines:
Code: Select all
Driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT,true);
tex = Driver->addTexture(name,img);
Driver->setTextureCreationFlag(video::ETCF_ALWAYS_32_BIT,flg32);
Driver->setTextureCreationFlag(video::ETCF_ALWAYS_16_BIT,flg16);
delete texd;
[b]img->drop ();[/b]
cached = true;
Code: Select all
sprintf(name,"TTFontGlyph%d_16",idx);
video::IImage *img = Driver->createImageFromData(video::ECF_A1R5G5B5,core::dimension2d<s32>(imgw16,imgh16),texd16);
tex16 = Driver->addTexture(name,img);
Driver->makeColorKeyTexture(tex16,video::SColor(0,0,0,0));
[b]img->drop ();[/b]
delete texd16;
2. CGUITTFace::load() creates and initializes whole TT library. That's not good cause it means only one font face can be load or every next face will create separate library object. You should consider creating library object separately in your program and passing it to CGUITTFace objects.
As I said CGUITTFace::load() creates 'library' object. Also 'face' object is allocated. Booth are never deleted. Simpliest solution will be to create destructor for CGUITTFace.
Code: Select all
class CGUITTFace : public IUnknown
{
public:
FT_Library library;
FT_Face face;
[b]CGUITTFace (): library (0), face (0) {};[/b]
bool load (const c8* filename);
[b]~CGUITTFace ();[/b]
};
Code: Select all
[b]CGUITTFace::~CGUITTFace () {
FT_Done_Face (face);
FT_Done_FreeType (library);
}[/b]
This should purge all memory leaks.
Greetings,
Grzegorz Sojka (ghs
[at]o2.pl)