What are some of the best ways to optimize a Titanium app?

前端 未结 1 333
再見小時候
再見小時候 2021-01-14 11:29

I have a titanium based iOS app that basically is following my own MVC structure. It has around 30 views and a lot of network connections to do API calls. So, it seems that

相关标签:
1条回答
  • 2021-01-14 12:09

    You mostly have to care about memory leaks. You have a VERY important webcast on the subject. In short; be very careful to :

    • avoid big global objects : they have references to the world, so these references won't be cleared
    • eliminate any circular dependances : the garbage collector is NOT a garbage collector ! It just count references and kill objects when there is 0 refs. With circular objects, there is always 1 ref.
    • Avoid events on Ti.App : ouch that sucks ! But the object that ask addEventListener is for ever in the Ti.App listener bus. The bus keeps a reference to send the event to that object, so it will be there forever, so will be its references.
    • Be careful with other events.
    • Be also careful with animations : they have callbacks that have references to the application. These callbacks are function (so variables) that may stay in memory, so do its references.

    In short, your application must be as close as possible to a simple tree with no backward reference. Write myDownObject=null when you go up in the tree. Use HEAVILY Instruments on your mac, with a 'Proxy' filter. All titanium objects are UIProxy.

    0 讨论(0)
提交回复
热议问题