[FINAL] Ensure the memory clearing function is called.


A slightly more general version of @tonidero's  https://github.com/mindsnacks/moai-dev/pull/75

Good team work gents.