Click here to Skip to main content
15,894,039 members
Home / Discussions / C#
   

C#

 
AnswerRe: share Pin
Le centriste24-Nov-08 2:10
Le centriste24-Nov-08 2:10 
QuestionRemove instance Pin
RishiKasnia24-Nov-08 1:00
RishiKasnia24-Nov-08 1:00 
AnswerRe: Remove instance Pin
Pedram Behroozi24-Nov-08 1:15
Pedram Behroozi24-Nov-08 1:15 
GeneralRe: Remove instance Pin
RishiKasnia24-Nov-08 1:41
RishiKasnia24-Nov-08 1:41 
GeneralRe: Remove instance Pin
Pedram Behroozi24-Nov-08 1:54
Pedram Behroozi24-Nov-08 1:54 
GeneralRe: Remove instance Pin
RishiKasnia24-Nov-08 1:58
RishiKasnia24-Nov-08 1:58 
GeneralRe: Remove instance Pin
Bijesh24-Nov-08 3:02
Bijesh24-Nov-08 3:02 
AnswerRe: Remove instance Pin
Simon P Stevens24-Nov-08 3:05
Simon P Stevens24-Nov-08 3:05 
I didn't realise you were using WPF.

WPF controls don't have Dispose methods because they don't need them. WPF controls don't use any unmanaged resources.

To release the memory used by a WPF control all you have to do is make sure you have no references to it, and the garbage collector will automatically clear up all the memory next time it runs.

Events are something to watch out for. Remember that the event source holds a reference to the event sink, so yes if you have a control sinking events from a source on a main form, then you will need to make sure you detach the event handlers if you want the control to be released.

Note that the garbage collector does not immediately remove the object from memory. the GC only runs occasionally, and when there is a requirement for more memory than is available. This is normal behaviour and there is nothing wrong with it. if you want to test things you can call GC.Collect() to force a collection and see if your memory is cleared up, but you shouldn't leave this in the code when you release it. The GC is carefully balanced, and forcing unnecessary collections can really screw up it's performance.

If you are still having problems getting the object to be cleared up, you can use WinDbg and SOS to peer deeper into the objects on the heap and work out why they aren't being collected. (Getting started with WinDbg & SOS[^],
How to find a GC leak[^], Memory leak detection in .Net[^])

Simon

GeneralRe: Remove instance Pin
RishiKasnia24-Nov-08 16:43
RishiKasnia24-Nov-08 16:43 
QuestionSetting Socket.ReceiveBufferSize Pin
HosamAly24-Nov-08 0:40
HosamAly24-Nov-08 0:40 
AnswerRe: Setting Socket.ReceiveBufferSize Pin
Mark Salsbery24-Nov-08 7:14
Mark Salsbery24-Nov-08 7:14 
GeneralRe: Setting Socket.ReceiveBufferSize Pin
HosamAly24-Nov-08 20:43
HosamAly24-Nov-08 20:43 
GeneralRe: Setting Socket.ReceiveBufferSize Pin
Mark Salsbery25-Nov-08 5:42
Mark Salsbery25-Nov-08 5:42 
Questionsmart card Pin
ellllllllie24-Nov-08 0:34
ellllllllie24-Nov-08 0:34 
QuestionA blocking operation was interrupted by a call to WSACancelBlockingCall Pin
Gareth H24-Nov-08 0:27
Gareth H24-Nov-08 0:27 
AnswerRe: A blocking operation was interrupted by a call to WSACancelBlockingCall Pin
led mike24-Nov-08 5:02
led mike24-Nov-08 5:02 
GeneralRe: A blocking operation was interrupted by a call to WSACancelBlockingCall Pin
Gareth H24-Nov-08 5:37
Gareth H24-Nov-08 5:37 
GeneralRe: A blocking operation was interrupted by a call to WSACancelBlockingCall Pin
led mike24-Nov-08 5:56
led mike24-Nov-08 5:56 
GeneralRe: A blocking operation was interrupted by a call to WSACancelBlockingCall Pin
Gareth H24-Nov-08 7:24
Gareth H24-Nov-08 7:24 
QuestionCapturing SessionEnding without Main form Pin
__DanC__23-Nov-08 23:21
__DanC__23-Nov-08 23:21 
QuestionThis is about material. I am Mongolia. I don't speak english Pin
Tsodgorhuu23-Nov-08 22:27
Tsodgorhuu23-Nov-08 22:27 
AnswerRe: This is about material. I am Mongolia. I don't speak english Pin
Simon P Stevens23-Nov-08 22:36
Simon P Stevens23-Nov-08 22:36 
GeneralRe: This is about material. I am Mongolia. I don't speak english Pin
Thomas Weller23-Nov-08 22:41
Thomas Weller23-Nov-08 22:41 
GeneralHelp me Pin
Tsodgorhuu23-Nov-08 22:42
Tsodgorhuu23-Nov-08 22:42 
AnswerCross post, please ignore Pin
Giorgi Dalakishvili23-Nov-08 22:40
mentorGiorgi Dalakishvili23-Nov-08 22:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.