Driftwood2D / Driftwood

Driftwood 2D Tiling Game Engine and Development Suite
http://tileengine.org/
MIT License
24 stars 1 forks source link

Crash from cache purging in-use resources #111

Closed pmer closed 7 years ago

pmer commented 7 years ago

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 calls CacheManager.reverse_purge, leading to the resource getting removed from the cache twice which crashes.

Also,

pmer commented 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.

pmer commented 7 years ago

What have other PySDL games done?

seisatsu commented 7 years ago

Good question. There is actually not a very big PySDL2 community.