Preserve timeline-created instances from removed-child cleanup#43
Open
Tutez64 wants to merge 1 commit intoopenfl:masterfrom
Open
Preserve timeline-created instances from removed-child cleanup#43Tutez64 wants to merge 1 commit intoopenfl:masterfrom
Tutez64 wants to merge 1 commit intoopenfl:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This sets
__removedChildCleanupDelay = Math.POSITIVE_INFINITYon display objects created by the Animate and SWFLite timelines.These timeline instances are intended to be reused after being removed from the display list. With the default OpenFL behavior, removed-child cleanup may run immediately and dispose internal cached state before the instance is reused.
Dependency
This PR depends on the companion OpenFL PR that adds delayed removed-child cleanup support: openfl/openfl#2850.
Why this change is needed
The end-user symptom is not perfectly reproducible on every machine because it depends on OS/runtime/native memory behavior.
That said, the underlying issue is deterministic:
This patch aligns the cleanup behavior with the actual lifecycle of those instances.
Observed effects
On the most affected systems, native memory could previously start near its normal baseline and then climb to several gigabytes within roughly ten minutes. After this change, it stays close to the initial baseline over the same period, or only increases slightly and an order of magnitude more slowly.
I also observed cases where memory was already relatively stable, but the initial/native memory footprint was still reduced after this change. For example, on a native Linux build of the same project, RAM usage dropped from about 790 MB to about 670 MB while remaining very stable.
Other testers also reported lower initial memory usage on Windows, even on machines where the original issue was less severe.
Suggested validation
If you want to verify the effect on your side, I think the most representative test would be a medium/large project that uses many SWF files and already consumes a noticeable amount of RAM. A very small sample may not show a meaningful difference.