EDIT: we ended up removing this in this PR; it had too many corner cases and confusion. The original text of this post is below, but this is not how SDL3 does things now.
We have an interesting new thing in SDL3.
Any library that returns allocated memory to an app has a conundrum to solve: who owns this memory?
Say, you have a function like "GetAudioDeviceName" that returns a string like "SoundBlaster Pro 16". Somewhere we need to have a block of memory of an arbitrary length to hold that string.
So maybe GetAudioDeviceName should call strdup() on its internal copy of the string and returns the new copy to the app, and the docs say "this is yours, so be sure to free it when you're done with it!"
And sometimes the app does. But sometimes it doesn't, and you have a memory leak.
So maybe GetAudioDeviceName should say: we already have a copy of this string we hold internally, let's just give them our pointer to it (as a const char pointer) and they just forget it when they're done.
And this works. Until it doesn't.
Let's say instead of "SoundBlaster Pro 16" the string is "My Awesome USB Audio Headphones" and, of course, the user is absolutely going to rip out the headphone plug when they rage quit the game.
SDL is going to say "whoa, this device has been unplugged!" and clean up all the data associated with it. Including that string it handed the app earlier. Which the app is still using to draw the device name in a config menu every frame.
So the app was using the memory, understanding they don't "own" it, but there were no guarantees as to how long it would live.
One could argue that for this example, the app should have allocated a copy of the string for itself, but let's say SDL returned that string as the user was unplugging the device...it's possible that the memory becomes invalid while the app is copying the string.
This will not do.
SDL3 is solving this problem in a fairly unique way. All allocated memory returned from SDL API calls is now owned by SDL unconditionally. Apps use it and do not free it. We call this "temporary memory."
And memory returned this way has a guaranteed lifespan, so it won't ever vanish in the middle of a printf() call or whatever. The memory lives until the next time you pump the event queue, in which case SDL clears out any temporary memory that's built up to that point, or until you call SDL_Quit, where we clean out everything because we're shutting down. In practice, maybe a handful of strings get cleaned up per-frame and the system runs smoothly, memory never leaks, and the app doesn't have to manage any of this at all.
But what if the app wants to use this data for a longer time? They can take ownership of it! By calling SDL_ClaimTemporaryMemory(thePointer) the memory is no longer owned by SDL, and the app will have to eventually SDL_free() it when done. As an added benefit, this saves the need to copy the data, as the app owns the original now. In most cases, claiming memory is the exceptional case, so we think this is an easier system than the app having to free every pointer that comes through.
There is one more technical detail, however: your main thread keeps memory until it processes events, but what about other threads? SDL keeps track of temporary memory per-thread, and for other threads will keep it around for at least one second and will clean it up then, or when the thread completes. This keeps allocations low and makes sure the memory survives long enough to be safely used.
We think this is a unique approach to a problem that developers have struggled with since the invention of malloc(), and it'll reduce memory leaks and crashes, and as is always most important, make programming with SDL3 more fun.