WriteableBitmap Memory Leak?

前端 未结 5 1163
花落未央
花落未央 2020-12-30 01:48

i am using the code below to create a live tile, based on an UI element. It renders the uiElement on a WriteableBitmap, saves the bitmap + returns

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-30 02:10

    Your finally in the try catch should be wbmp = null for a kick off.

    And you are rendering it, which means you are attaching that object to an outside (the function) list. Therefore no amount of GC.Collect will actually collect it as it's still 'in play'.

    Set the uielement source to null, that may get rid of the attached reference why the GC is ignoring it.

提交回复
热议问题