Skip to content

TFS+3D LRT fix; PoP1 Apple II reset fix#23

Merged
GMPranav merged 4 commits intomainfrom
memory-leak-fix
Dec 3, 2025
Merged

TFS+3D LRT fix; PoP1 Apple II reset fix#23
GMPranav merged 4 commits intomainfrom
memory-leak-fix

Conversation

@saulm314
Copy link
Member

@saulm314 saulm314 commented Dec 2, 2025

TFS + 3D

We were subscribing to the game.Exited event but we never unsubscribed, which means that the ASL script object cannot be garbage collected until the process object is garbage collected. Although here in practice it (probably) doesn't cause a memory leak since as far as I know there is no case where the same process object is still alive while another ASL script object is created, it's still a bit dangerous because if (even in a future LiveSplit update) something references that process object, it will prevent the ASL script object from getting garbage collected as well.

Also, the script wasn't actually removing time when the game isn't running (though GMP tells me it worked before, so perhaps a new LiveSplit feature broke it?). For TFS this didn't matter because the other LRT conditions were already sufficient to freeze the timer when the game isn't running. I don't know if this made a difference for PoP 3D. Either way it's been fixed now.

PoP1 Apple II

The reset condition that was based on the game not running was inefficient and also it wasn't working (perhaps also because of a LiveSplit update?). Instead of checking the process name string every cycle (which involves reading every character of a string, and potentially a system call), we now simply check if the process object itself has changed. This should add virtually no overhead.

All

  • TFS has been verified to work
  • 3D hasn't been verified to work because I don't have the game, but the change is identical to TFS so it almost certainly works
  • PoP1 Apple II hasn't been verified to work; ideally it should be verified to work in two ways:
    1. With the exact script that comes with this pull request
    2. With the script that comes with this pull request, but replacing the reset block with just return vars.OldProcess != vars.CurrentProcess to verify that that part of the script works correctly (since the other reset conditions may obscure whether this condition works or not)

We were subscribing to the game.Exited event but we never unsubscribed, which meant that when we closed the game the Process object could not be garbage collected, thus every game restart would cause a memory leak in a new Process object. Although we never noticed, it is likely that 100 or more game restarts would have caused a performance issue and possibly even a bug in the script.
See description for previous commit - same applies here
@saulm314 saulm314 requested a review from GMPranav December 2, 2025 22:04
@saulm314 saulm314 changed the title TFS+3D memory leak + LRT fix; PoP1 Apple II reset fix TFS+3D LRT fix; PoP1 Apple II reset fix Dec 2, 2025
@saulm314 saulm314 closed this Dec 2, 2025
@saulm314 saulm314 deleted the memory-leak-fix branch December 2, 2025 23:56
@saulm314 saulm314 restored the memory-leak-fix branch December 2, 2025 23:56
@saulm314 saulm314 reopened this Dec 2, 2025
@GMPranav GMPranav merged commit f804a67 into main Dec 3, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants