Too many images render crash

My game has 12860 images loaded to memory use these function:

  1. SDL_RWFromMem
  2. IMG_LoadTyped_RW
  3. SDL_CreateTextureFromSurface

If the image count is 12800 the game running ok.
But when the image count is 12860 the game will crash.

The crash code location is ‘if (!_this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, egl_surface))’

The call stack start location is ‘SDL_RenderPresent( gRenderer )’

I know the problem is image count too large. But I don’t know use what API to detect the image count overflow. All my function call to create image return value is true.

who know use which API to detect the image loaded too much?

You could store an int that keeps track of the texture count evertime you call SDL_CreateTextureFromSurface and its creates a texture, increment the texture count.

What interests me is why you need to load 12800 + textures in memory at once ?

Can you use a texture atlas to combine similar textures into 1 texture ?

I’m knows the image count is 12860, because I track the count in an int as you say.
I’m test my game engine, which use SDL as the base, so I need too many images to be load.
On mobile, every device’s performance are not same. Some mobile can load images over 13000, but some will crash at 12000.
Bug I found the return value of the 3 function always true, even the app will crash.
So I want to know if there has any function to return an value let me know the image count is at limit?
I think the crash may be the memory full, may be the image create failed with an true return value.
Did some one has the same problem?