Object disposal and the ‘destruct’ section
Filed under: Technical
By Thomas Herchenröder @ July 3, 2008 4:26 pm
Recently, there was a lively thread on the mailing list concerning object disposal and the 'destruct' section of classes. While the corresponding wiki page gives most of the answers, it might be worthwhile to summarize and highlight a few aspects:
- Generally, qooxdoo's runtime will take care of most of the issues around object disposal, so you don't have to be too anxious if you get those 'missing destruct declaration' messages from a verbose disposer run.
- You can look at the dispose behaviour of your app if you set the disposer into a verbose mode and then invoke it deliberately while your app is running. This will usually render your app unusable, but you will get all those messages hinting you at object properties that might need to be looked after. How-To instructions can be found here. But mind that the disposer output are really hints, nothing more.
_disposeFields()is always a safe choice to use in the 'destruct' section of your class. And it prevents all DOM leaks which is the most important thing to do._disposeObjects()is appropriate when you want to dispose an attached qooxdoo object your class is in charge of. Whether this hold true depends on the application where objects might be shared between other class instances, so make sure you are not destroying an object some other class might want to continue to use
._disposeObjectDeep()is rather arcane, and you can safely ignore it in most cases. qooxdoo 0.8 will replace this method with two others,_disposeArray()and_disposeMap(), which are more straight-forward and just relieve you from using loops around iterable data structures for the dispose calls.
Hope this sheds some more light on the issue.
