Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6847] iOS: Setting a property directly to a TableViewRow will leak memory

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionCannot Reproduce
Resolution Date2017-05-26T14:10:15.000+0000
Affected Version/sRelease 1.8.0.1
Fix Version/sn/a
ComponentsiOS
Labelscore
ReporterMauro Parra-Miranda
AssigneeIngo Muschenetz
Created2011-12-22T11:34:23.000+0000
Updated2017-05-26T14:10:15.000+0000

Description

PROBLEM DESCRIPTION

Customer discovered that setting a property to a table row directly will lead to leaks and setting it using the setter will not.

STEPS TO REPRODUCE

1. Create new mobile project 2. Paste the above leaking code into the app.js 3. Run the app.

ACTUAL RESULTS

The app is leaking

EXPECTED RESULTS

Being able to modify values in the row without leaking

LEAKING CODE

var win = Ti.UI.createWindow({
            orientationModes:[Ti.UI.PORTRAIT]
         });

var tableView = Titanium.UI.createTableView({});
win.add(tableView);

function updateTable() {
    var data = [];
    for (var x=0; x< 10; x++) {
        var row = Ti.UI.createTableViewRow({
            className: "DataRow"
        });
        row.backgroundColor = "#FF0000";

        var label = Ti.UI.createLabel({
            text: "Label: " + x
        });

        row.add(label);
        data.push(row);
    }
    tableView.setData(data);
}

updateTable();
updateTable();

win.open();

NON-LEAKING CODE (using setter)

var win = Ti.UI.createWindow({
            orientationModes:[Ti.UI.PORTRAIT]
         });

var tableView = Titanium.UI.createTableView({});
win.add(tableView);

function updateTable() {

    var data = []; 
    for (var x=0; x< 10; x++) {
        var row = Ti.UI.createTableViewRow({
            className: "DataRow"
        });
        row.setBackgroundColor("#FF0000");

        var label = Ti.UI.createLabel({
            text: "Label: " + x
        });

        row.add(label);
        data.push(row);
    }
    tableView.setData(data);
}

updateTable();
updateTable();

win.open();

EXTRA INFO

As you see the only difference is row.backgroundColor = "#FF0000";(leaking) VS row.setBackgroundColor("#FF0000");(not leaking)

Comments

  1. Lee Morris 2017-05-26

    Closing this ticket as the issue cannot be reproduced with the following environment; iPhone 7 (10.2) MacOS 10.11.6 (15G31) Studio 4.9.0.201705021158 Ti SDK 6.1.0.v20170519131839 Appc NPM 4.2.9 Appc CLI 6.2.1 Ti CLI 5.0.13 Alloy 1.9.11 Arrow 2.0.0 Xcode 8.2 (8C38) Node v4.8.2 Java 1.7.0_80

JSON Source