Run: let go of the executable's bytes once it is loaded (228 MB RAM) #2151
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2151
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2151/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@desplmfao on GitHub · 2026-11-25 06:19 UTC · original
desplmfao:fix/drop-image-buffers→main· +3 −0 · 1 files · 1 commits · closed without mergingProblem
run()reads the executable into aVec(original) and makes a patched copy of it for the loader (prepared.bytes). Both are locals ofrun(), which only returns when the title exits. So the process keeps two copies of the executable in memory for the whole run, although aftervictory_loader::loadthe patched copy is on disk and loaded, and neither buffer is used again.For Grand Theft Auto VI (Series X 1.0.2.1) the executable is 114 MB, so that's 228 MB held for nothing.
Change
drop((original, prepared))right aftervictory_loader::load. Nothing after that point uses either.imagedoesn't borrow them; the compiler would refuse the drop if it did.Measured
Allocations of 1 MiB or more tracked by call site, with a counting global allocator (diagnostics only, not part of this PR). RTX 5080, Linux, proton-cachyos 11.0:
std::fs::readinrun()victory_loader::prepareTested
cargo clippy -p victory --all-targets -- -D warnings: clean.AI-assisted (Claude Code).
🤖 Generated with Claude Code
@desplmfao on GitHub · 2026-11-25 06:25 UTC · original
Closing as a duplicate of #2071, which makes the same change and came first. I missed it when I searched. For #2071, the measurement from here: tracking allocations of 1 MiB or more by call site in Grand Theft Auto VI, the two 114 MB blocks (
std::fs::readinrun()andvictory_loader::prepare) are gone, and VIctory's heap in the menu goes from 1,092 to 863 MB. RTX 5080, Linux, proton-cachyos 11.0.Pull request closed