[SDL] iOS Memory Warnings - Small Fix; How To Improve?

Gorm Lai gorm at kotoristudios.com
Tue Mar 12 05:12:40 PDT 2013

Hi All,

So, I have been unable to find a way to handle or detect iOS memory warnings through SDL. 

The main issue is that memory warnings are usually raised by the system through the AppDelegate or ViewControllers, which are both abstracted away by SDL. My current solution has been to patch the SDL code with the following small snippet in SDLUIKitDelegate.

- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
  SDL_Event event;
  event.type = SDL_USEREVENT;
  event.user.code = 0xCAFEBABE;

This works well, and I just grab the event in my game's event pump. However, I see that both event.type and event.user.code need to be changed from what I have used. I really would like to change this into something that could eventually be used a real patch, as memory warnings happen all the time in iOS (and I assume Android) and should be reacted upon.

I couldn't really find any good event type to match, except perhaps SDL_SysWMEvent, which is why I used SDL_USEREVENT. Maybe a SDL_SYSTEMEVENT or SDL_MEMORYEVENT could be created, and then as the subtype introduce something like SDL_MEMORYWARNING, or maybe the subtype is not even needed?

Suggestions are very welcome.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20130312/5e4c368e/attachment-0008.htm>

More information about the SDL mailing list