SuRGeoNix/Flyleaf

WinUI Memory Leak & Possible Fix

Closed this issue · 1 comments

I'm making the video camera related application like below:
297656366-dfc036d2-098f-489a-89fe-3a89b3fc5e12

Since it uses multiple camera feeds, I noticed that FlyleafLib.Controls.WinUI has a memory leak problem.

The image below is a memory usage screenshot of my program after creating 10 instances of FlyleafHost.
image

It's over 600+mb, and if I comment out the "Player" allocation code from Flyleaf Host, it doesn't cause the memory leak problem.

After some investigation, I found that if I add the lines of code highlighted below, the memory leak doesn't happen anymore.
image
image

Below is the screenshot of my application with the same condition after adding the two lines of code above.
After

Edit: removed CI/BI

Hi @airtaxi and thanks for the finding. SwapChain release will cause issues but for WinUI it seems to work fine now. The issue comes from the SwapChainPanel that keeps a reference inside it and it should be disposed but currently using a single instance for the template.