Fix bug24 memory error when clean object

Hi @wqking, I noticed this branch didn't have a PR created for it so I am doing it now, I'll also assign WIP label to mark it as work-in-progress.

Once a branch is pushed to github, you can create a PR from either the main screen (if its a recent push), or go to a compare branches page and create it from there. more info - https://help.github.com/articles/creating-a-pull-request