Fix MultiThread debug element memory leak #1564
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I saw a memory leak which may (still under tests) be the source of my recent failing tests on LG TVs (the application restarted after one or two hours of playback).
It only appears in a combination of experimental features, so not dramatic either:
I noticed that a debug-related Promise's
reject
callback was correctly linked to theInit
'sCancellationSignal
but was never unbound from it.As such, that
CancellationSignal
, which is alive as long as the content is playing, would keep a reference to that reject function, and this seems to extend to other objects linked to that Promise. I was for example under the impression that even that Promise's resolved value was retained by looking at Chrome's inspector's "memory tab".The solution is simply to unbind
reject
from the CancellationSignal when either "rejecting" or "resolving" the Promise.I also profited from this fix to transform the
resolvers
object from a simple JS Object to aMap
as it seems much more appropriate: we most frequently insert and remove values from it, and we never need to serialize that object.Also that Object's keys were number and to my understanding JS Object keys are always stringified (or at least you cannot have e.g.
[1]
and["1"]
point to different values) so that didn't seem natural to me, plus the fact that I initially feared that it was an array.