Why is there still the problem with memory leak ?

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


    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
    — answered 4 years ago by JC Guerrero
    1 Comment
    • Dear JC Guerrero !

      Thank you so much for your answer, and your time to write all this ! i know, you are right, and as i said, i love Titanium and the guys behind Appcelerator. RESPECT !! But some time, it is really frustrated. i worked 10 months on my app (alone) and then i found the memoryleak :-( My App is in the appstore and it works on iPad2 and the new iPad. But on iPad1 (because of the small RAM "256MB") the app crashes often after some minutes (3 - 6 Min) and this makes me Arrrgghhhhh , but anyway !! Thanks again for your great answer ! And it's also good to know, that i'm not alone with this problem :-) I will try some things you wrote !

      Greetings from Switzerland!

      By the way: This is the app "ConsolesHD"
      inline ConsolesHD in iTunest

      — commented 4 years ago by Hansjuerg Wuethrich
  • 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.


  • 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 !!

    — answered 5 years ago by Hansjuerg Wuethrich
    • 1.7 is out

      — commented 5 years ago by Neil Whitehead
    • Yeahh ! I have to test it! Thank you !

      — commented 5 years ago by Hansjuerg Wuethrich
    • I only see 1.6.2 …? where do you find 1.7?

      — commented 5 years ago by Alexander van der Werff
    • Drop-down-menu -> Master

      — commented 5 years ago by Hansjuerg Wuethrich
    • k, thanx, I tried it, but not really a difference.

      — commented 5 years ago by Alexander van der Werff
    • with 1.7 there is still the same Problem ! After 120 - 180 Seconds, the App says "Bye bye Baby !" Memory Overflow :-(

      — commented 5 years ago by Hansjuerg Wuethrich
    • Unfortunately I have the same problem. Because of some fixes in 1.7 and 1.8. I now switched my project to (my app is already available in the app store). Since using 1.8 (before 1.6) my memory problems got even worse! In principal the new app update is done, but I cannot submit to the app store because after playing the app for about 10 minutes nearly all memory has gone! I feel a little bit lost.

      — commented 4 years ago by Stephan Lenhart
  • Hansjuerg, if you post the code for your main memory leak app, instead of accusing Titanium, maybe we could help…

    — answered 5 years ago by Luc Martin
    • I think he is understandably frustrated. There are many threads regarding memory leaks that have not been answered. Mainly around scrollableview and refreshing tableviews with images. The latter being a showstopper for one of my apps. Even more frustrating as for most developers the leaks only show up after the hard work has been done on the simulator only to find that on the device it fails.

      — commented 5 years ago by Neil Whitehead
    • Well what timing!! It looks like one has been resolved in 1.7 though as yet untested
      Hold on in there Hansjuerg!

      — commented 5 years ago by Neil Whitehead
    • Guys, read my post below, it is guaranteed to work. My usage scenario: 1000 image views, 500 rows of data, 7 tabs. Works just dandy.

      — commented 5 years ago by Michael Peng
    • I saw your post about the memory pool, I even created a singleton class inspired on it… but in my scenario the images (within a tableview) are placed in windows stacked in a navigationgroup, so hitting the back button will close a window containing a bunch of images and your method should not be necessary since it is also based on window closing. While checking the available memory on a close event, I do not see it going up (or very little)…

      — commented 5 years ago by Alexander van der Werff
    • I am having the same usage scenario as Alexander.. Even when closing a window it does not appear the available memory is increasing. I'm getting annoyed with this issue as well, certainly because I just started with Titanium for a couple of days and my project is going great, but when you are searching for developpers with the same issue you will find unanswered questions about this topic that are dating from October 2010. You are busy more trying to fix this memory issue than creating an Iphone app.

      — commented 5 years ago by Nicky Vandevoorde
    • yes it is true, i'm also frustrated about that. This are basic functions. CLOSE a window should free the memory. Also Master 1.7 has the same problems :-( I hope for 1.8 that this will be fixed. otherwise my work of 10 months is just a piece of shit. :-(

      — commented 5 years ago by Hansjuerg Wuethrich
    • Recently I found out that there is some sort of cache mechanism build in Titanium, which will load remote images from a dictionary with the key value its url… it seems it all works when there is enough resources available on the device. When there are a lot off apps running on the background the app seems to crash faster… this is for iPhone 4.

      — commented 5 years ago by Alexander van der Werff