Skip to content

Fixing Memory leak in ThemeChangeEvent#446

Merged
pomianowski merged 2 commits intolepoco:developmentfrom
FelixT42:main
Oct 28, 2022
Merged

Fixing Memory leak in ThemeChangeEvent#446
pomianowski merged 2 commits intolepoco:developmentfrom
FelixT42:main

Conversation

@FelixT42
Copy link
Copy Markdown

The ThemeChangedEvent was added in ClientAreaBorder and TitleBar but never removed. This caused that windows that uses this elements are never removed from memory what causes an memory leak.

Pull request type

Please check the type of change your PR introduces:

  • Update
  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes

What is the current behavior?

There are a few ThemeChangedEvents added to the static ThemeChangedEvent Changed in Theme.cs .
When multiple windows are opended and closed this handler prevents the garbage Collector from removing the classes from memory. If the application is not closed, the memory consumption can grow constantly.

Issue Number: N/A

What is the new behavior?

The Handlers are removed from the static variable to allow the GC to collect the windows and clean up the memory.

Other information

Behaviour before my changes. I just opend and closed a few windows with a lot of elements on:
Open and closed Windows with Bitmaps, dotMemory

In DotMemory I could see that there a leaking Event Handlers:
Event1 in dotMemory

I tracked them down and saw that there are coming form ThemeChangedEvent:
Event in dotMemory

After implementing my changes the amount of Memory drasticly are reduced:
After Chart dotMemory

Also the leaking Handlers:
Reduced handlers dotMemory

pomianowski and others added 2 commits September 26, 2022 00:33
@FelixT42 FelixT42 requested a review from pomianowski as a code owner October 26, 2022 13:57
@github-actions github-actions Bot added the controls Changes to the appearance or logic of custom controls. label Oct 26, 2022
@pomianowski pomianowski changed the base branch from main to development October 28, 2022 21:46
@pomianowski pomianowski self-assigned this Oct 28, 2022
@pomianowski pomianowski merged commit 0fd4ab2 into lepoco:development Oct 28, 2022
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Oct 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

controls Changes to the appearance or logic of custom controls.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants