Why is there still the problem with memory leak ?

You must Login before you can answer or comment on any questions.

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 3 years ago by JC Guerrero
answer permalink
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 3 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
answer permalink
  • 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

  • Show 4 more comments

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
answer permalink
  • 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

  • Show 4 more comments

Your Answer

Think you can help? Login to answer this question!