Skip to content

fix: release completed Swiftly timer references - #357

Closed
Flegma wants to merge 1 commit into
mainfrom
fix/release-swiftly-timers
Closed

Flegma wants to merge 1 commit into
mainfrom
fix/release-swiftly-timers

Conversation

@Flegma

@Flegma Flegma commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

One-shot Swiftly timers are dropped from TimerUtility.Timers once they run.

  • AddTimer kept every one-shot token in Timers after it fired, so the list only grew over a long session.
  • A one-shot that ran, was cancelled, or threw now removes only its own entry; tokens stay owned by SwiftlyS2.
  • Repeating timers and Kill are unchanged.

Tested: apps/swiftly/test (1534 passed), three new TimerUtilityTests cases.

One-shot timers stayed in TimerUtility.Timers after they ran, so the list grew for the life of the plugin. A finished or cancelled one-shot now removes its own entry, also when its callback throws.
@lukepolo

Copy link
Copy Markdown
Contributor

Closing. The leak is real but tiny. SwiftlyS2 cancels a fired one-shot's token and drops its own reference to it. Ours keeps a few dozen bytes per timer until the plugin unloads, which is tens to low hundreds of timers per match. Not worth the change.

If this comes back:

  • The tests call RunOnce by reflection, so they still pass if AddTimer stops going through it. On main they fail with a NullReferenceException because the method is missing, not because of the leak.
  • A test through AddTimer with a fake ISwiftlyCore / ISchedulerService (DispatchProxy) catches both.
  • The CSS TimerUtility grows the same way.

@lukepolo lukepolo closed this Nov 24, 2026
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