Closed pmer closed 7 years ago
My first thought here is that we can maintain a reference count for cache-able objects and then we call _terminate()
when the last reference is up. But to do this, we need to make sure we deref cache-able objects held by any Python object, which means we need to be able to run code on every single object's destructor. But we know CPython doesn't support this so that's not feasible.
It would also mean we're manually managing memory which means we're fighting Python since it's a garbage collecting language.
What have other PySDL games done?
Good question. There is actually not a very big PySDL2 community.
The cache purges all resources after a set timeout, even if they are still in use. The cache calls the resources'
_terminate()
which in turn callsCacheManager.reverse_purge
, leading to the resource getting removed from the cache twice which crashes.Also,
_terminate()
the music a third time.Invalid texture
errors on SDL_RenderCopy and the game exits since a frame failed to draw correctly.