I'm starting to work with Sencha Touch 2 and I just wondered how does it (if even) handle resource cleanups.
imagine we have a bunch of controllers which are triggered by url redirects. Will those Controller instances be cached or is Sencha creating fresh instances everytime that it needs to invoke a method on a controller
Same for views. Does sencha cache views or will it recreate them everytime it needs to render them again. When exactly are views destroyed (if they are)?
can I get control on how sencha handles those things?
To answer your questions,
Only one instance of each controller is created by Sencha. So, I really think you do not need to bother about the controller instances. Let Sencha handle that.
The cleanup should actually be done with the Views because the number of views and complexity of them are closely related to the performance.
Suppose on clicking a button, user opens an INFO popup which shows some information about the page. Once the user read the info, he closes the popup. Now, from a user perspective, there may be a very little chance that the user will re-open the popup. So, best will be if the popup gets removed from the DOM as soon as user closes it. Anyhow, if the user wants to re-open it, re-create the popup and show it.
Similarly suppose user is in login page and signing in to the application. Users hardly go back to the login page while within the app. So, destroy the login View instance once its hidden.
So, these are some scenarios where the Views can be removed explicitly when needed. Below are some references which gives good idea about the memory optimization with Sencha:
a) Sencha Touch: Optimizing Memory Usage