Sascha Füller
1/21/2005 8:46:00 PM
Hello everybody,
does anybody know what System.Drawing.Internal.SystemColorTracker is doing?
The reason I ask this is a strange behavioer I found in my application.
I think I can fix the problem, but the behavior of this component
(SystemColorTracker) seems really confusing.
As I was profiling memoryusage of my application I recognized that over some
time many thousands instances of WeakReference were created (about !! 100000
!! in half an hour, using memory of 1,5MB)
While looking deeper into it I recognized that all these Instances get
created by a call to SystemColorTracker.Add when SolidBrush.set_Color is
called.
I looked into it some deeper with Reflector and looked what this component
does.
- Everytime I set a SystemColor to my SolidBrush.Color-Property, then
SystemColorTracker is called and a WeakReference is created.
(in my application the color is changed many thousand times and so many
thoused WeakReferences to the same object are created)
- But what I find really confusing is that all methods and mempers of
SystemColorTracker are private and only the Add-Method is internal,
and it seems that nobody is here to reuse the WeakReference.
But what can I do with such a "WriteOnly" object?
Thanks in advance
Sascha