开发者

Custom attributes not getting garbage collected?

开发者 https://www.devze.com 2023-01-29 15:59 出处:网络
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 co

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

Custom attributes not getting garbage collected?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消