-
Notifications
You must be signed in to change notification settings - Fork 665
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
Memory leaks in unpackaged C++-Desktop-App #9534
Comments
For the first leak you mention here, it is a harmless leak.
The following is the left over detected blocks of memory left allocated:
I'm not going into how I released that last reference to Application because it is guaranteed to leave a dangling pointer somewhere in the Xaml runtime. While it doesn't cause problems now for short periods after it is deleted, there is no guarantee that there will never be a use after free in the future. If you want to work it out yourself, it is basically obtaining the ABI interface and releasing it without an AddRef or QI. But this is certainly not something that you should do, I'm only doing it here to illustrate a point. The remaining two blocks could be related to the dispatcher queue, which I don't believe gets shut down either. But these are harmless because the amount of blocks does not grow and Windows will reclaim the memory when the process' heap gets destroyed when the process exits. However, I understand that these leaks can get in the way of debugging. |
Thank you, Darran, for clarifying the facts. That at least explains that part. And yes, of course this makes troubleshooting more difficult and should definitely be fixed. |
In my opinion, an application that generates its own graphical elements and updates their display regularly is a standard use case. If such applications cause the user systems to crash, this is highly critical. Accordingly, this problem should also be classified here! |
Describe the bug
I created an unpackaged desktop app with the VS template "Blank App, Packaged (WinUI 3 in Desktop)" and only added some code (_CrtSetDbgFlag etc.) to detect memory leaks. When the app is started and stopped again with VS, memory leaks are shown.
Then I added some code that draws something in a canvas again and again to demonstrate rapidly growing storage requirements when an app has to update drawn content periodically.
Steps to reproduce the bug
UnpackagedDesktopApp_MemLeak_SDK1_5_1.zip
...
Expected behavior
No memory leaks.
No growing memory requirements due to updated drawings.
Screenshots
No response
NuGet package version
Windows App SDK 1.5.1: 1.5.240311000
Packaging type
Unpackaged
Windows version
Windows 10 version 22H2 (19045, 2022 Update)
IDE
Visual Studio 2022
Additional context
No response
The text was updated successfully, but these errors were encountered: