Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25051] Android. persistentObjects leak

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2017-11-14T00:30:37.000+0000
Affected Version/sRelease 6.1.2
Fix Version/sRelease 7.0.0
ComponentsAndroid
Labelsn/a
ReporterSergey Volkov
AssigneeGary Mathews
Created2017-07-19T12:44:38.000+0000
Updated2017-11-15T06:26:37.000+0000

Description

https://github.com/appcelerator/titanium_mobile/blob/6_1_X/android/modules/network/src/js/network.js#L16 https://github.com/appcelerator/titanium_mobile/blob/6_1_X/android/modules/network/src/js/network.js#L27 https://github.com/appcelerator/titanium_mobile/blob/6_1_X/android/modules/ui/src/js/ui.js#L18 https://github.com/appcelerator/titanium_mobile/blob/6_1_X/android/modules/ui/src/js/ui.js#L29 Objects references should not be deleted by "splice", because they might be disposed not in the same order what they were stored.

Comments

  1. Sergey Volkov 2017-07-19

    I suggest to replace current realisation with something like this:
       // Keeps an object alive until dispose() is called.
       // This is currently used to keep "top level" objects
       // (ex: windows, tab groups) alive until their lifecycle ends.
       function PersistentHandle(object) {
       	this.cell = PersistentHandle.lastId++;
       	PersistentHandle.objects[this.cell] = object;
       }
       
       // Objects retained by persistent handles.
       // Each element in this array acts as a storage "cell"
       // keeping the object reachable and alive until it is removed.
       PersistentHandle.objects = {};
       
       PersistentHandle.lastId = 0;
       
       PersistentHandle.prototype.dispose = function() {
       	if (this.cell == -1) {
       		// This handle has already been disposed.
       		return;
       	}
       
       	delete PersistentHandle.objects[this.cell];
       	this.cell = -1;
       }
       
  2. Sergey Volkov 2017-08-04

    https://github.com/appcelerator/titanium_mobile/pull/9276
  3. Abir Mukherjee 2017-11-14

    FR passed; PR's merged.

JSON Source