grimfang4/SDL_FontCache

Memory leak in FC_DrawBox?

Opened this issue · 4 comments

Hey!

It is possible I am doing something wrong since I am kind of new with C++, but I looked at the memory usage for my application and noticed that whenever I was using FC_DrawBox() in my main loop memory usage increased with about 1 MB every half minute or so.

This shows some of the code:

int main(int argc, char* argv[])
{
...
while (AppIsRunning)
{
...
// works, no problems -->
FC_Draw(font,renderer,10,10,"hello world");
// works, but causes memory leak -->
FC_DrawBox(font,renderer,FC_MakeRect(10,10,100,100),"hello world");
...
}
...
}

Could you confirm that this is the correct way to use the FC_DrawBox or am I doing something wrong? Cause when I do that the memory start increasing. The problem is only with FC_DrawBox, not in FC_Draw. If I comment out FC_DrawBox there is no memory increase.

Your snippet looks fine. I'll poke through FC_DrawBox() to see where it might be leaking. The logic in FC_GetBufferFitToColumn() is what I suspect, since that implementation is pretty messy in plain C.

Hmm... Well I'm not yet able to reproduce this with my test program.
Running it through Dr. Memory didn't produce anything either. Can you send
a minimal complete program that this happens to?

Okay, I re-downloaded the zip file for SDL_FontCache and added the latest files to my project and did a total rebuild and it appears I am not having this problem anymore.

I don't know if you made any changes that fixed this or if I did something wrong in my application earlier, but there is no problem with the memory anymore, it stays the same now, no memory leak. I guess this is not an issue anymore.

Nope, no changes over here. I wish you no more memory bugs!