Tuesday, February 07, 2012 7:50 AM
I found a memory leak of System.Windows.Forms.Application+ThreadContext when IE loaded managed toolbar.
Each time i open a new tab, the ThreadContext will be constructed. but after I close the new tab, the ThreadContext won't be detroyed.
It seems that a static Hashtable keeps the instance of the ThreadConext. It won't be removed from the hashtable.
the following is the gcroot command result in windbg:
0:015> !gcroot 03e23954 Scan Thread 6 OSTHread 1e84 Scan Thread 8 OSTHread 1860 Scan Thread 9 OSTHread 1ea8 DOMAIN(0019B640):HANDLE(Pinned):3cb13ec:Root:04e13250(System.Object)-> 03e13108(System.Collections.Hashtable)-> 03e13140(System.Collections.Hashtable+bucket)-> 03e131dc(System.Windows.Forms.Application+ThreadContext)
How could I remove this leak?
Thursday, February 09, 2012 11:14 AMModerator
I would suggest you to create control in the main window thread, not a non-UI thread. You can check this link:
Jesse Jiang [MSFT]
MSDN Community Support | Feedback to us
Thursday, February 09, 2012 3:00 PM
I never created controls in a non-UI thread. All controls are created in the Tab Window thread. Also, my managed Toolbar was created in the Tab Window thread and created by IE.
- Edited by Calvin Kwok Thursday, February 09, 2012 3:01 PM