Correct Memory Management (SSK2)

_ Note: _  the title of this post isn’t the best, but I couldn’t come up with one that was clearer.  Let me explain.

A forum member (who shall remain un-named) PMed me a question about camera coding and a leak he’d encountered as well as his fix.  Another part of this PM was some code he’d tried that didn’t work as expected.

  

I don’t generally answer PMs of this nature because I prefer open discussions that everyone can benefit from.  However, the question was interesting, so…

To answer (or at least talk to) the concepts covered by the request I made a sample that does a proper (correct) job of creating and destroying composer.* scenes that use an SSK2 camera, easyInput, and other features.

The goal of this sample was to show how to create, destroy, create, destroy, … a scene’s content repeatedly simply by using the scene listeners and code, not by forcibly destroying the scene with removeScene().  

While doing all this, we don’t want to see any memory leaks or other issues.  This is about the management of content and the proper destruction of that content.

Anyways, here is a video:

https://www.youtube.com/watch?v=bE1z5n3NphA

, and here is a direct link to the download: 

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2016/12/correct_management.zip

(Yes, this uses SSK2 lite or PRO), but even with out SSK2 you can read the code and see what it does.