Titanium JIRA Archive
Alloy (ALOY)

[ALOY-435] UI Object Allocations with Alloy and Titanium Studio

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionCannot Reproduce
Resolution Date2013-03-08T23:05:48.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsRuntime
LabelsAllocations, Alloy, Memory, UI
ReporterAppDesign
AssigneeTony Lukasavage
Created2012-12-19T17:57:45.000+0000
Updated2014-01-29T00:07:02.000+0000

Description

The attached project has only 1 window and 1 view with 10 buttons so that you could see the UI count in allocations. In the attached screen1.png you will see view1 with the 10 buttons. In the attached screen2.png - If you click the remove myself button you will see that the view is removed and nulls the global reference to the view and you are returned to the window (white). I stayed on the window for a long time on a couple of tests and it never cleaned up the UI objects from view 1. In attached screen3.png I opened view1 and clicked the remove myself button and the objects where cleaned up almost instantly. I can repeat this action over and over again and the objects clean up flawlessly. This confirms that if you went to a view and never returned to it, it would never be properly cleaned up. Here is a link to the simplified project and made it as "hello world" as I could in hopes of making the issue easier to spot. http://wwww.appdesigngeeks.com/simpleviewtest.zip Below is the simplified code from Alloy.js that does the open and close of view1 Alloy.globals.VARS = { globalParent: null, // Store ref to Parent Window of App globalCurrentView: null, // Store ref to current view being shown }; Alloy.globals.GVUpdate = function(inName, inValue) { Alloy.globals.VARS[inName] = inValue; }; Alloy.globals.GVOpenViewNew = function(viewName) { var openingview = Alloy.createController(viewName); // create controller Alloy.globals.VARS.globalParent.add(openingview.getView()); openingview.init(); Alloy.globals.VARS['globalCurrentView'] = openingview; }; Alloy.globals.CloseView = function() { Alloy.globals.VARS.globalParent.remove(Alloy.globals.VARS.globalCurrentView.getView()); // Remove Current View from Parent Alloy.globals.GVUpdate("globalCurrentView", null); // Cleanup by Releasing resources and memory for current view };

Attachments

FileDateSize
screen1 .png2012-12-19T17:57:45.000+0000388659
screen2.png2012-12-19T17:57:45.000+0000363100
screen3.png2012-12-19T17:57:45.000+0000360694

Comments

  1. Tony Lukasavage 2013-01-09

    The linked project is not a valid download link so this is impossible to test. It's also worth noting that memory is not freed the instant that you remove and null a resource. Garbage collection needs to kick in before any of that will happen and that's probably why as you continue to navigate around your app that it is freed. Update the project link and we can revisit.
  2. AppDesign 2013-01-10

    Hi Tony, Sorry about the link, it had an extra w in the www. Here is the correct link http://www.appdesigngeeks.com/simpleviewtest.zip. I understand that garbage collection does not always kick in at a certain time or always right away. I have let the screen sit there for hours and the view never gets cleaned up. I also have another example with more views and if you navigate to a 4th view and then back through the app and never return to the 4th view it will never get cleaned up no matter how many times I navigate around the rest of the views (ex. view1, view2, and view3) in the sample app or how long I let the app run. Hope this helps Thanks
  3. Tony Lukasavage 2013-01-10

    Is the "leak" growing over time though? It sounds like this is a discrete example that doesn't in fact grow but instead represents the memory footprint of your app as it relates to the timing of the garbage collection. I guess what I'm asking is does the number of views in memory grow over time, or is it just this instance that stays there? Because if it doesn't grow, it's not really a leak. If it does grow, are you able to recreate the issue without your custom logic? I have not been able to recreate any leaks without using the custom view management.
  4. Tony Lukasavage 2013-03-08

    Will reopen if more details are given

JSON Source