Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19861] Alloy Collection - Dealing two or more collections at the same time causes memory leak

GitHub Issuen/a
TypeBug
Priorityn/a
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsn/a
ReporterShawn Lan
AssigneeUnknown
Created2015-08-28T19:26:52.000+0000
Updated2018-02-28T19:55:45.000+0000

Description

Create a default Alloy project with the following: index.js
Alloy.createCollection("samplea").fetch();
Alloy.createCollection("sampleb").fetch();
$.index.open();
index.xml
<Alloy>
	<Window />
</Alloy>
models/samplea.js
exports.definition = {
	config: {
		"columns": {
			"id":"INTEGER"
		},
		"adapter": {
			"type": "sql",
			"collection_name": "sampleas",
			"idAttribute":"id"
		}
	},

	extendModel : function(Model) {
		_.extend(Model.prototype, {
		});

		return Model;
	},

	extendCollection : function(Collection) {
		_.extend(Collection.prototype, {
		});

		return Collection;
	}
};
models/sampleb.js
exports.definition = {
	config: {
		"columns": {
			"id":"INTEGER"
		},
		"adapter": {
			"type": "sql",
			"collection_name": "samplebs",
			"idAttribute":"id"
		}
	},

	extendModel : function(Model) {
		_.extend(Model.prototype, {
		});

		return Model;
	},

	extendCollection : function(Collection) {
		_.extend(Collection.prototype, {
		});

		return Collection;
	}
};
Using xCode instrument "Leaks" to monitor the app. Soon after launching the app, there appear several leaked objects.

Comments

  1. Shawn Lan 2015-08-29

    I've done more testings. It doesn't need to be two different collections. The following produces the same result:
       Alloy.createCollection("samplea").fetch();
       Alloy.createCollection("samplea").fetch();
       
    However, if the second fetch() is run long after the first fetch(), there is no leaked object:
       Alloy.createCollection("samplea").fetch();
       setTimeout(function(){Alloy.createCollection("sampleb").fetch();},3600000);
       
  2. Sharif AbuDarda 2015-11-04

    Hello, This is still a bug in the latest releases. I tested with Studio 4.3.3.201510212245. Ti SDK 5.0.2.GA and iOS 9.1. The memory leak occurs. I also tried [~shawnlan] test with two similar collections. The result still the same. Thanks.

JSON Source