Closed philippe-wm closed 3 months ago
We found that Lightning occasionally tries to double-release textures.
The problem is that when freeing a texture, this updates the Stage total used memory: https://github.com/rdkcentral/Lightning/blob/dev/src/tree/TextureManager.mjs#L164
Unfortunately ANY total memory usage update can cause an immediate GC: https://github.com/rdkcentral/Lightning/blob/dev/src/tree/Stage.mjs#L452
This can cause a race condition where a texture release can cause a GC run re-releasing the texture before it has finished the initial release.
Prevent Stage to run GC when updating the total memory with a negative delta:
const _addMemoryUsage = stage.addMemoryUsage; stage.addMemoryUsage = (delta) => { if (delta < 0) { stage._usedMemory += delta; } else { _addMemoryUsage.apply(stage, [delta]); } };
Possibly related issues: #492, #520, #521
Issue
We found that Lightning occasionally tries to double-release textures.
The problem is that when freeing a texture, this updates the Stage total used memory: https://github.com/rdkcentral/Lightning/blob/dev/src/tree/TextureManager.mjs#L164
Unfortunately ANY total memory usage update can cause an immediate GC: https://github.com/rdkcentral/Lightning/blob/dev/src/tree/Stage.mjs#L452
This can cause a race condition where a texture release can cause a GC run re-releasing the texture before it has finished the initial release.
Workaround
Prevent Stage to run GC when updating the total memory with a negative delta:
Possibly related issues: #492, #520, #521