Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-3166

significant memory leak with thumbnails in tableview

    Details

      Description

      {html}<div><p>We are using Titanium 1.6RC1 with Developer 1.2.2 and think we
      have found a significant memory leak when displaying remote
      thumbnails in a tableview. Below is the code to reproduce.</p>
      <p>Upon running the code, just attach to the process using XCode
      Instruments. Then click the "Photos" button to bring up the grid of
      photos, then click back to close the window. Continue to do this
      over and over again and you will see the living memory allocations
      continue to increase to extremely high levels.</p>
      <p>Why doesn't closing a window free up all it's memory usage? I
      come from the Objective-C world and have created this same screen
      natively with no memory leaks. Am I missing something in our
      javascript code? This is a showstopper for us if we cannot find a
      solution.</p>
      <p>Thanks!</p>
      <p>Brian</p>
      <pre>
      <code>var tabGroup = Titanium.UI.createTabGroup({id:'tabGroup1'});

      win = Titanium.UI.createWindow({id:'win1',backgroundColor:'#fff'});
      var button = Ti.UI.createButton({title:'Photos',width:100, height:100});

      button.addEventListener('click', function() {
      var photosWindow = Titanium.UI.createWindow({fullscreen:false});
      var tableView = Ti.UI.createTableView({ separatorStyle:Ti.UI.iPhone.TableViewSeparatorStyle.NONE });
      photosWindow.add(tableView);

      tab1.open(photosWindow, {animated:true});

      var xhr = Titanium.Network.createHTTPClient();
      xhr.onload = function() {
      var list = JSON.parse(this.responseText).List;
      var rowData = [];
      for (var i = 0,count = list.length; i < count; i += 4) {
      var row = Ti.UI.createTableViewRow({ height:'auto', selectedBackgroundColor: '#fff', backgroundSelectedColor: '#fff', className:'tvRow' }),imgDimensions = 80;


      var offSet = 0;
      for (var j = 0; j < 4; j++) {
      var photo = list[i + j];
      if (photo) {
      var photoView = Ti.UI.createImageView({ top:0, left:offSet, height:imgDimensions, width:imgDimensions, image:photo.ThumbnailUrl });
      row.add(photoView);
      offSet += imgDimensions;
      }
      }
      rowData.push(row);
      }
      tableView.setData(rowData);
      };
      var url = "http://idancemobile.com/event/e2e530/api/2.0/images/0";
      xhr.open("GET", url);
      xhr.send();
      });

      win.add(button);

      var tab1 = Titanium.UI.createTab({
      id:'tab1',
      window:win
      });

      tabGroup.addTab(tab1);

      tabGroup.open();</code>
      </pre></div>{html}

        Attachments

          Activity

            People

            • Assignee:
              rseagraves Reggie Seagraves
              Reporter:
              brian Brian
            • Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Git Source Code