Fix memory leaks related to the debug window.
Merge branch 'release_31' into development

Fix memory leaks related to the debug window.