[TIMOB-25051] Android. persistentObjects leak
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Critical |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2017-11-14T00:30:37.000+0000 |
| Affected Version/s | Release 6.1.2 |
| Fix Version/s | Release 7.0.0 |
| Components | Android |
| Labels | n/a |
| Reporter | Sergey Volkov |
| Assignee | Gary Mathews |
| Created | 2017-07-19T12:44:38.000+0000 |
| Updated | 2017-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.
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; }https://github.com/appcelerator/titanium_mobile/pull/9276
FR passed; PR's merged.