[Scummvm-devel] Freeing resources on quit
Max Horn
max at quendi.de
Sun Oct 6 11:48:02 CEST 2002
At 19:33 Uhr +0100 05.10.2002, Ruediger Hanke wrote:
>Hello,
>
>I have a problem with resource leaks on quitting ScummVM in my
>MorphOS port. It's because ScummVM doesn't shutdown properly
>but just uses exit() for quitting.
>
>The biggest problem is the MIDI of Simon the Sorcerer. Étude isn't closed
>on exit, the user has to reset before he can start another MIDI app.
It's besides the point I guess, but shouldn't a system level service
be automatically "intelligent" enough to free all resources taken by
an application when it quits?
>How about implementing some "proper" quit? I'd do this if nobody
>else has time or considers it important ... but I'd need to know how
>to do it. Because the System instance doesn't know about the engine,
>the only thing I could think of would be another function in the
>system interface that can be queried by the Engine whether it should
>quit ...
I don't quite understand where the problem is, as we already have a
quit() method in the system interface. Why can't you just change the
remaining parts that call exit() to use the system->quit() method
instead?
As for freeing all resources, that is tricky with the current
approach (which relays on the OS being "clever" enough to free all
occupied resources when the program terminates). Also note that we
have event loops in various places, not just one central event loop.
One possible way around this would be to use C++ exceptions to "quit"
the application, we could use this to "gurantee" the top main
funciton is reached - but of course this will cause serious problems
when used in threads/signal handlers.
Could you please state what exactly you need to do? You only gave a
very vague description, and with that it's kinda hard to give good
advice. Personally I'd not like to rewrite everything just so that we
can free all resources we ever allocate, as a) it's not necessary on
most OSes and b) slows down the program termination (at least on
MacOS it can make a difference).
Max
--
-----------------------------------------------
Max Horn
Software Developer
email: <mailto:max at quendi.de>
phone: (+49) 6151-494890
More information about the Scummvm-devel
mailing list