Proper Way to Close Window?

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

Hi. I have a simple question regarding memory management when dealing with multiple windows. I have many windows that I open from my app.js file in the following manner:

var detailWindow = Ti.UI.createWindow({
    url:'details.js',
    backgroundColor:'stripped'
});
Then, inside these windows, I have various elements. (Textfields, imageviews, labels, tableviews, etc.)

What would be the proper way to close them and release memory?

Is detailWindow.close() good enough? Or do I need to set every element inside it to null before closing it?

I have noticed that when I close the windows and open them, the data they contained shows for a fraction of a second before updating. This leads me to believe that they don't close properly and free memory. What do you think?

— asked 2 years ago by Guvvy Aba
0 Comments

3 Answers

Accepted Answer

When you open the window with the url parameter (as you are), I believe closing the window IS enough to release all the memory. The post referenced by Imraan is for single context apps which do NOT use the url parameter.

In my apps which use multiple contexts, I have never had a problem due to memory leaks from windows -- to my knowledge.

— answered 2 years ago by Doug Handy
answer permalink
2 Comments
  • Thanks. Also, is navGroup.close(window) sufficient if a window is opened in a navGroup?

    — commented 2 years ago by Guvvy Aba

  • It is what I do, when the window is in an iOS navGroup.

    — commented 2 years ago by Doug Handy

No detailWindow.close() is not good enough. Check out this post to help with memory woes

http://developer.appcelerator.com/question/116867/this-is-a-solution-to-your-memory-woes

Just create a heavy weight window(just add fullscreen:false) and upon closing them , you will release all the memory consumed by it.

Your Answer

Think you can help? Login to answer this question!