Program takes too much memory

前端 未结 1 623
[愿得一人]
[愿得一人] 2020-12-22 05:01

I\'m using WPF to develop a simulator of Conway\'s Game of Life.

From some reason, sometimes the program takes up to 400,000K memory (When I draw a lot of cells real

相关标签:
1条回答
  • 2020-12-22 05:32

    This is the result of using a DrawingContext/DrawingVisual. It's actually benign and should all be garbage collected as the system needs it, but the memory usage can be alarming. If you were to, instead, draw shapes on a canvas then you would probably not see this problem. I've run into this same issue with custom drawn controls in the past. Switching to more vector-based drawing techniques (i.e., shapes on a canvas) fixed the memory consumption problem.

    0 讨论(0)
提交回复
热议问题