simple problem I think, but I have problem with freeing surface, cuz RAM is overflowing even if I add SDL_FreeSurface() to my code. Without this function RAM is fine. There's something more to "free" in this code? This code is trying to make text (score for ping pong game) on the top of the screen.
TTF_Init();
TTF_Font* arial = TTF_OpenFont("arial.ttf", 32);
SDL_Color msg_color = { 255,255,255 };
char msg[128];
sprintf_s(msg, "%d %d", g_SCORE_P_LEFT, g_SCORE_P_RIGHT);
SDL_Surface* messageSurface = TTF_RenderText_Solid(arial, msg, msg_color);
SDL_Texture* Message = SDL_CreateTextureFromSurface(m_game_window_renderer, messageSurface);
SDL_Rect msg_rect;
msg_rect.x = 50;
msg_rect.y = 50;
msg_rect.w = 30;
msg_rect.h = 30;
SDL_RenderCopy(m_game_window_renderer, Message, NULL, &msg_rect);
SDL_FreeSurface(messageSurface);
TTF_Quit();
You're freeing the surface, but you're not freeing the texture that was created based on it. Add this line to the end:
SDL_DestroyTexture(Message);
You will also need to close your font:
TTF_CloseFont(arial);
It's also good practice to close SDL_TTF. Add this line just before SDL_Quit();
TTF_Quit();