Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing Memory leak in ThemeChangeEvent #446

Merged
merged 2 commits into from
Oct 28, 2022
Merged

Conversation

FelixT42
Copy link

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

@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