i can't believe it ! since months there is a heavy memory leak in Titanium. We can't create good looking Apps for iPad with lots of graphics. Now i'm working since October 2010 on a iPad App but can't go further beacuse of the memory leaks! Dear Appcelerator team, you did a great work and Titanium is really cool and special, but please in the name of all App developers. Please give us the posibilities to free memory by our self ! The "REMOVE" command is useless, because it does not free the memory !
4 Answers
Accepted Answer
Hansjuerg:
It is important to understand that Titanium is a proxy pseudo compiler for JavaScript that delegates some handling to both iOs and Android to end up doing the rest of the work. In Java which is a completely GarbageCollector Orientated Langage: you still need to have some precautions in order to avoid eating up all the memory. JavaScript is no exception. I found myself very frustrated at first with Titanium, but we have to realize that this is JavaScript doing fishy stuff, not Titanum; and we only realize it because finally we are working with limited specs devices instead of PCs and WebBrowsers.
I've come to realize that most of the problems posted in this forum are because people think of JavaScript as a poor wannabeC seudolanguage, when in fact its [almost] at Python's level, which is by far one of the most beautiful languages on earth :) If you wish to use Titanium but won't bother extending your JavaScript knowledge... it's bound to blow up in your face
Some key JavaScripts concepts that if you study further will help understand the management of memory:
Prototype-Orientated
Parasitic inheritance
Dictionaries are prototype structs!! (and all Titanium objects take dictionaries as params)
Garbage Collection in JavaScript
Using commonJS and exports/require wisely (look for titanium require monkeypatch)
Assignments ARE References (this is the C equivalent to the pointer of the object and not the object itself)
Null assignment
Deep Copy
'new' keyword
Finally some Titanium specific recommendations:
include and require are not enemies, know when to use each one
Avoid 'new' when possible, or the ghost instances will end up haunting you
Know where to addListeners. in a Table you can add either 1 listener and search for the firing row, or add listeneres to every row... which turns into more objects, which feeds the GC...
If you cling all your objects to a "memory cleaning", the GC will fail to detect it... and you have to do the cleaning yourself.
Know your local resources: FireEvents with dictionaries attached, Titanium.App.Properties, sqlite, folders (including cache)
Know your folders: Resources, applicationDirectory, applicationSupportDirectory, externalStorageDirectoy, etc.
- Cache what you can in folders that the user can dispose
you can always reclaim memory by manually sticking views/objects that you would like to be freed into an empty window then calling close on the window.
http://developer.appcelerator.com/question/116867/this-is-a-solution-to-your-memory-woes
Hansjuerg, if you post the code for your main memory leak app, instead of accusing Titanium, maybe we could help...
First of all. i still love Appcelerator Titanium. They did a great job for a great framework !! But i'm frustrated (and i'm not alone with this!!). As i told you, i'm working since Oktober 2010 on a project and now in the halftime i get this memory leak error. This makes me crazy and frustrated, because i can't fix the error by my self. After the use, i remove all the unused objects in the code : mainWindow.remove(Logo01); and so on, but the objects still remains in memory and after 2 minutes of use the app hangs up !
I do not accuse the Appcelerator Titanium Team , i was just frustrated. Please let me say "SORRY!!"
I'm looking forward for the 1.7 Update. Thank you !!
Your Answer
Think you can help? Login to answer this question!