core: Various memory optimizations #18773
Draft
+126
−86
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.
Draft, as I still want to test it a bit more.
This makes us no longer copy compressed image data from SWFs to vecs.
The most extreme cases (100+MB SWFs like mardek, EBF), this can save up to 12-15MB of memory (we have like 600MB of RAM use by the time preloader finishes in Mardek: Nineveh mod). For average SWFs this is probably closer to <1MB.
Any loading speedup is insignificant compared to time spent in DefineShape.
OwnedJpeg is needed because of optionally appending
jpeg_tables
inDefineBits
; I could move them to become lazy too (and this way everything could beSwfSlice
), but this'd mean we repeat this work each time weloadBitmap()
or SymbolClass-construct a BitmapData; it's a rare combo, but I'd rather not risk sometimes doing duplicate work until a possible refactor to deduplicate the entire image decoding work.EDIT: added a similar improvement for Sounds; should have between 30-80% of most SWFs' size. Best I've seen was 50-80MB, but for most SWFs it'll be closer to 1-2MB or less.