Consider detaching game from DevToolsService when not needed

Open
#3,316 1 comment 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@filiph is already working on this.

Since Sep 21, 2024.

Assessment

This issue has not been assessed yet.

Description

enhancement
What could be improved

Not a big deal, but currently, when running a game in debug mode, any FlameGame that is ever started will forever be retained in memory unless replaced with a different FlameGame.

From FlameGame's constructor:

    if (kDebugMode) {
      DevToolsService.initWithGame(this);
    }

There is no DevToolsService.detachGame() or anything similar.

Screenshot 2024-09-21 at 14 25 08

Why should this be improved

This can be confusing when one's looking at memory (albeit I agree that one should be normally doing that in profile mode) and sees a game that's supposed to be gone a long time ago, and won't go away even after manual GC.

This almost sent me on a wild goose chase for a giant game-sized memory leak.

Risks
  • Some people might want to inspect their game after it's been disposed?
  • Could introduce a DevTools connector bug where game's disposed too soon, for example.
More information

I'm not sure myself if this is something worth addressing. Just putting this here before I forget.

Other
  • Are you interested in working on a PR for this?
Dominant language
Dart
Stars
10.8k
Forks
1.1k
Avg merge
2d 4h
Merged PRs (30d)
61

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from flame-engine/flame

All issues in flame-engine/flame

Similar issues

More Dart issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.