Custom attributes not getting garbage collected?
In my WPF application we have various custom controls, dependency properties in these controls use various attributes like SortOrder
, MaxLength
etc.; these attribute values are used in PropertyGrid
control to identify Sort Order etc. for a particular property.
Using ANTS profiler I came to know that these attribute objects always remain in memory, even though original custom controls are no longer in mem开发者_Python百科ory. Profiler shows this retention graph for these attributes - http://weblogs.asp.net/blogs/akjoshi/CustomAttributeRetentionGraph.png
I am not sure why this is happening any leads?
An Attribute
is associated with type and not an instance of a type.
Whenever a type is loaded, all attributes will be loaded associated with that type. And this will only happen once for a type, which means if you create 100 instances of that type, attributes will be loaded only once.
I guess they stay in memory till application exits.
精彩评论