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

WPF -Possible Memory Leak when toggling ViewModel visibility when ViewModel contains a Chart #1468

Open
WillickDN opened this issue Mar 22, 2024 · 0 comments

Comments

@WillickDN
Copy link

Describe the bug
Using '2.0.0-rc2' though verified as far back as '2.0.0-beta.800' it was present.

I have a main view that contains a collection of views/viewmodels. Each ViewModel contains a cartesian chart (and a few other small controls like labels and buttons).

For some search functionality, I was building in the ability to filter out viewmodels and hide from display any that doesn't match the search.

When a Viemodel that contains the cartesian chart goes from "Collapsed" visibility, to "Visible" I've noticed a large increase in memory that never goes away.

It appears that the chart is being redrawn each time, and something in the points isn't getting disposed. I've included a screenshot of the heap difference between one chart (1000 points) going from invisible, to visible.

I have a sample application that has a button that toggle the visibility of the chart. No new calculations are done or generated. Just hide the view model and show it. And in the Visual Studio debugger you can see the memory increasing each time you toggle it back into view.

To Reproduce
Steps to reproduce the behavior:

  1. Add Cartesian Chart to View.
  2. Hide the whole chart (not just the series from the chart)
  3. Display the chart again.
  4. Notice an increase in memory used.

Expected behavior
I expect when just toggling visibility that the chart wouldn't need to redraw and take up extra memory.

Screenshots
image

You can sort of see in this image each time I redisplay the viewmodel
image
(I know this isn't crazy numbers, but I am using a small sample at the moment, not the case in prod)

Desktop (please complete the following information):

  • OS: Windows 11

Additional context
Added my sample application. Just a main window with a toggle button and a single viewmodel with a chart in it. Clicking the toggle button should make the memory increase.
LiveChartMemorySample.zip

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

No branches or pull requests

1 participant