How to clean Sencha Touch 2

I'm starting to work with Sencha Touch 2, and I'm just wondering how it (if even) handles resource cleanup.

In particular:

  • Imagine we have a bunch of controllers that are caused by URL redirection. Will these Controller or Sencha instances be cached, creating new instances each time he needs to call a method on the controller.

  • The same goes for views. Does the cache view represent sencha or will it be recreated every time it needs to display them again. When exactly are species destroyed (if any)?

  • Can I get control over how sencha handles these things?

+7
source share
1 answer

To answer your questions,

  • Sencha creates only one instance of each controller. So I really think that you do not need to worry about controller instances. Let Sencha handle this.

  • Cleaning should be done using views, because the number of views and their complexity are closely related to performance.

Sencha does not purge its resources on purpose - the developer should explicitly take care of cleaning the DOM (except for the Javascript garbage collection mechanism). Thus, the developer needs to decide when to create the view, whether to save it in the DOM for future use or to destroy it immediately after hiding it. Let me give you some examples:

but.

Suppose that when a button is clicked, the user opens an INFO popup that shows some information about the page. As soon as the user reads the information, he closes the pop-up window. Now, from the user's point of view, there can be very little chance that the user will again open a pop-up window. So, it would be best if the popup is removed from the DOM as soon as the user closes it. Anyway, if the user wants to re-open it, recreate the pop-up window and show it.

IN.

Similarly, if the user is on the login page and enters the expression. Users are unlikely to return to the login page of the application. So, destroy the Login View instance after hiding it.

Thus, these are some scenarios in which views can be deleted explicitly if necessary. Below are some guidelines that give a good idea about memory optimization with Sencha:

a) Sencha Touch: optimizing memory usage

b) http://www.slideshare.net/senchainc/optimizing-performance

+11
source

All Articles