I’m wondering about high memory usage when I call SDL_LockTexture. I have a window that is 1024x576, and a streaming texture that is 256x144. When I just call SDL_RenderCopy and SDL_RenderPresent, my app uses 130MB. If i call SDL_LockTexture/SDL_UnlockTexture each frame, my app uses 259MB. Is this typical? Here is all I’m doing, as you can see I’m not even updating the texture yet:
void* pixels;
int pitch;
if (!SDL_LockTexture(render_texture, NULL, &pixels, &pitch))
{
SDL_UnlockTexture(render_texture);
}
SDL_RenderCopy(renderer, render_texture, NULL, NULL);
SDL_RenderPresent(renderer);
It just seems like a lot of memory to me. I know it’s not really in the big picture. The real issue is that I actually have 6 different windows (for debugging) that I also do this with, and my memory usage jumps up to 1.8GB. Now those windows won’t be in the release build. I guess I just wanted to know if I’m doing things wrong.
SDL_LockTexture() winds up doing at least 1 allocation somewhere, whether by SDL itself or by the GPU driver, because it has to create space for the memory returned in the pixels variable. There may be intermediary allocations made by the GPU driver as well.
As long as memory usage isn’t continually climbing then it’s probably fine.