dotnet / dotnet/wpf

Atom table leak after window running on a separate thread closes (Check the demo)

Open
#3,971 27 comments 4 reactions 0 assignees View on GitHub
.NET Framework Investigate
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

* .NET Core Version: Not tested
* Windows version: Win10 20H2
* Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes

**Problem description:**
If a window is started on a separate thread, after the window closes, the atom created using RegisterWindowMessage is not destroyed/released as long as the program is running. As the max atom table size is 16384, This will finally cause an outofmemory exception.

**Minimal repro:**
[openwindowInNewThread.zip](https://github.com/dotnet/wpf/files/5790088/openwindowInNewThread.zip)
Just run the demo above, and use [this tool](https://github.com/JordiCorbilla/atom-table-monitor) to monitor the atom table count. By opening and closing the new window (it's running on a separate thread) repeatedly, you can see the RWM atom count keeps rising, and falls down after the program exits.
![image](https://user-images.githubusercontent.com/14279372/104081768-ca10a980-526b-11eb-977f-c25c4da4934a.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.