Hi,
I am doing my best follow Ti Studio's best practices and I have the following situation/question.
I have a module inside which there is a table view where each row is the id to an ACS place. When a row is clicked I call the following function:
var openDetail = function( placeId ) { var Location = require('ui/Location').Location; var locationDetail = new Location(placeId); appname.ui.currentTab.open(locationDetail); };and open another module which pulls the corresponding ACS place and renders its details.
The problem which I am encountering is that: when I hit 'back' inside the detail view (to get back to the original window with the table view) and then reopen the detail view for another location a few times, memory (presumably allocated for the ui related to each location) gets 'trapped' and the performance of the detail view degrades significantly.
Another manifestation of the same problem is that: if I open the detail view for one and the same location twice but change the data in ACS before the second time I open it, I get the two versions of the data/ui rendered on top of each other.
So my question is: what is the proper way to remove the old detail view and free up the memory associated with it before I open it a second, third, fourth time?
Thanks.
1 Answer
Accepted Answer
I have used the same technique with much success, and I have not seen the performance degradation you describe. I'm not doing anything special to manage the memory of the detail view, either.
When you close the detail view and open a second detail view, the locationDetail now references the second detail view. Nothing should be referencing the first detail view. Therefore, the garbage collection should clean it up, along with all its child views.
How do you know this is a memory issue, and not something else? Have you profiled the app? Are you looking at memory usage through another tool?
What if you try opening up a "dummy" window with no controls (or minimal controls)? Do you have similar slowdowns?
There could be something else wrong with your code that is causing the issue.
Your Answer
Think you can help? Login to answer this question!