Remove Control
-
i have created a user control Dynamically and added it to a Wrap Panel as a child. now if i remove it from panel but it still remains in memory. i want it to be permanently removed from memory. There is no Dispose method available. and i also tried by implementing idisposable interface and overwriting the Dispose() method for my control but it still remain in memory. Is there any way to remove this object(User Control) from memory Regards Rishi
-
i have created a user control Dynamically and added it to a Wrap Panel as a child. now if i remove it from panel but it still remains in memory. i want it to be permanently removed from memory. There is no Dispose method available. and i also tried by implementing idisposable interface and overwriting the Dispose() method for my control but it still remain in memory. Is there any way to remove this object(User Control) from memory Regards Rishi
RishiKasnia wrote:
Is there any way to remove this object(User Control) from memory
Nope. WPF uses MIL handles internally, and the garbage collector is called as and when it is needed. When you think about it, this makes perfect sense - the whole point of WPF is that it doesn't need you to access unmanaged resources to do things (you can, but you aren't required to) so you don't actually need to Dispose controls.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
-
RishiKasnia wrote:
Is there any way to remove this object(User Control) from memory
Nope. WPF uses MIL handles internally, and the garbage collector is called as and when it is needed. When you think about it, this makes perfect sense - the whole point of WPF is that it doesn't need you to access unmanaged resources to do things (you can, but you aren't required to) so you don't actually need to Dispose controls.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
Thanks Pete for reply but in my case i need to remove this user control from memory . becoz after removing it from canvas or panel , if i try to fire some event then this Control also respond the event (Though it has been removed). for a workaround i detached the Event Handler for user control(when i remove it from canvas/panel). but it still resides in memory and remains throughout the program execution (becoz this control is not local to any Block) thus degrading performance . Regards Rishi.
-
Thanks Pete for reply but in my case i need to remove this user control from memory . becoz after removing it from canvas or panel , if i try to fire some event then this Control also respond the event (Though it has been removed). for a workaround i detached the Event Handler for user control(when i remove it from canvas/panel). but it still resides in memory and remains throughout the program execution (becoz this control is not local to any Block) thus degrading performance . Regards Rishi.
Unfortunately you can't automatically remove the control deterministically. You could, possibly, remove the control by forcing a garbage collection, but this really is a bad idea.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith