Uploaded image for project: 'Alloy'
  1. Alloy
  2. ALOY-915

Alloy Collection (RESTful) is not releasing memory properly

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Medium
    • Resolution: Won't Fix
    • Affects Version/s: Alloy 1.3.0
    • Fix Version/s: None
    • Component/s: Runtime
    • Labels:
    • Environment:

      TiSDK 3.2.0.GA

      Description

      Issue description

      Alloy Collection is not releasing memory properly if fetch is run WITH a callback.

      Steps to reproduce

      Ti project files here: https://www.dropbox.com/sh/f4h0fkyp08numrm/W9rvtLZ1Rr

      • To run the app WITH a memory leak:

      1) In the ledgerlists.fetch({.... ; lines 15-18 of test1.js ; UNCOMMENT these lines and build the app. To be clear, the lines to un-comment are:

      success: function(collection, response)

      Unknown macro: { console.log("fetch finished"); console.log(response); }

      2) Run Instruments

      select "Allocations" icon, click "Choose"
      pick the drop down box "Choose Target"
      select "Attach to Process" ->
      scroll down to the "System" heading area, then underneath that, find the app (leakTest1)
      click on Record (top left); enter uid/pwd if needed on mac osx
      in the top right corner of Instruments window, put "TiUI" to the filter box <enter>
      now go back to the Ti app that is open/running
      open up the modal window by clicking on the "TEST1" button
      close the modal window (then take a look at Instruments)
      open up the modal window again, then look at Instruments
      repeat 11 & 12 a number of times (5 or 6)
      you should see the number of retained objects for the listview increasing. they never get released.

      • To run the app WITHOUT a memory leak:

      1) In the ledgerlists.fetch({.... ; lines 15-18 of test1.js ; COMMENT OUT these lines and build the app. To be clear, the lines to COMMENT OUT are:

      success: function(collection, response)

      Unknown macro: { console.log("fetch finished"); console.log(response); }

      **RE-SAVE & CLEAN BUILD OF Ti PROJECT

      Repeat the above steps 2.->13. to watch Instruments

      You should not see any memory leak. All the objects are eventually released.

      Thoughts

      We tried out to unbind the Collection using reset method after the Controller Window closed:

      E.I. http://stackoverflow.com/questions/9202599/how-do-i-unbind-a-backbone-collection-fetch-callback

      Since "Using reset with no arguments is useful as a way to empty the collection." http://docs.appcelerator.com/backbone/0.9.2/#Collection-reset

      We are seeing the Ti objects getting released after the 3rd or 4th time (Under #transient column) Screen shoot: AlloyMemoryLeak_Instruments.jpg

      Quoted the code lines that were added on our side for testing purposes (controllers/test1.js):

      $.closeButton.addEventListener('click', function(e)

      Unknown macro: { $.win1.close(); $.win1.removeAllChildren(); $.destroy(); ledgerlists.reset(); }

      );

      We also attempted to use the Alloy.Collections.instance method with the name of the model file minus the extension as the only parameter to create or access the singleton. However this ended up just getting released the TiWindow

      Screen shoot: AlloyCollection_SingletonInstance.jpg

      For example (controllers/test1.js):

      // some restful endpoint - testing purposes only
      //var ledgerlists = Alloy.createCollection('ledgerlist');
      var ledgerlists = Alloy.Collections.instance('ledgerlist');

        Attachments

          Activity

            People

            • Assignee:
              tlukasavage Tony Lukasavage
              Reporter:
              egomez Eduardo Gomez (Inactive)
            • Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                  Git Integration