Hello guys,
First of all, sorry if this has been asked before, but I couldn’t find any answer related to my issue.
So I have this application, rendering to screen every 40ms (25fps).
One of the elements being rendered is a “wall clock”. This is the piece of code that takes care of creating the textures and copy it to the renderer.
if (viewport->main_window->common_camera_label_font && viewport->timestamp_text) {
SDL_Color rgbwhite = {191, 191, 191};
SDL_Surface* textsurface = TTF_RenderText_Blended(viewport->main_window->common_camera_label_font, viewport->timestamp_text, rgbwhite);
SDL_Texture* timestamp_texture = SDL_CreateTextureFromSurface(viewport->main_window->window_renderer, textsurface);
SDL_Rect timestamp_box = {
viewport->x_pos + viewport->width - textsurface->w - 5,
viewport->y_pos + 5,
textsurface->w,
textsurface->h
};
SDL_RenderCopy(renderer, timestamp_texture, NULL, ×tamp_box);
SDL_DestroyTexture(timestamp_texture);
SDL_FreeSurface(textsurface);
}
SLD_RenderPresent() is then called later once I’ve gone through all UI elements.
This seems to work fine, but over a long period of time, there’s a CPU usage increase (about 10% over a day). If I disable this piece of code, that does not happen.
If I would have to guess, it looks like there’s some internal list that gets bigger and bigger and iterating over it get more and more expensive?
idk… just spitballing.
Any ideas on what might be happening and the best way to fix it?
TIA