Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualBaneTrapper

Posted 12 August 2012 - 02:44 AM

EDIT:: The problem is fixed.

Hello.
Currently at my code i found i have a huge leak... around 8mb per sec, with future analysis i discovered the problem:
surf_Text1 = TTF_RenderText_Solid(FT_Font1, "Continue", TextCol);
	if(surf_Text1)
	{
		SDL_BlitSurface(surf_Text1, NULL, (*surf_Screen), &TextRec);
	}
surf_Text1 = TTF_RenderText_Solid(FT_Font1, "NewGame", TextCol); //Leak occurs here
	if(surf_Text1)
	{
		SDL_BlitSurface(surf_Text1, NULL, (*surf_Screen), &TextRec);
	}
This code would per run cause memory leak.
But it would clean at exit of program.
If you call TTF_RenderText_Solid/Blended/Shaded on a non (empty/NULL) SDL_Surface i would get a leak.
I fixed problem by doing this before every call of TTF_RenderText_Solid
SDL_FreeSurface(surf_Text1);


But i got dozen of TTF_RenderText_Solid per loop, and i don't want to lose performance. Any way to fix this without having to call SDL_FreeSurface before TTF_RenderText_Solid.

#1BaneTrapper

Posted 10 August 2012 - 11:17 AM

Hello.
Currently at my code i found i have a huge leak... around 8mb per sec, with future analysis i discovered the problem:
surf_Text1 = TTF_RenderText_Solid(FT_Font1, "Continue", TextCol);
    if(surf_Text1)
    {
	    SDL_BlitSurface(surf_Text1, NULL, (*surf_Screen), &TextRec);
    }
surf_Text1 = TTF_RenderText_Solid(FT_Font1, "NewGame", TextCol); //Leak occurs here
    if(surf_Text1)
    {
	    SDL_BlitSurface(surf_Text1, NULL, (*surf_Screen), &TextRec);
    }
This code would per run cause memory leak.
But it would clean at exit of program.
If you call TTF_RenderText_Solid/Blended/Shaded on a non (empty/NULL) SDL_Surface i would get a leak.
I fixed problem by doing this before every call of TTF_RenderText_Solid
SDL_FreeSurface(surf_Text1);


But i got dozen of TTF_RenderText_Solid per loop, and i don't want to lose performance. Any way to fix this without having to call SDL_FreeSurface before TTF_RenderText_Solid.

PARTNERS