Click here to Skip to main content
15,885,984 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: Is .Net 2.0 is backward compatible with .Net 1.1? Pin
Robert Rohde23-Jan-07 20:55
Robert Rohde23-Jan-07 20:55 
AnswerRe: Is .Net 2.0 is backward compatible with .Net 1.1? Pin
lmoelleb24-Jan-07 0:20
lmoelleb24-Jan-07 0:20 
GeneralRe: Is .Net 2.0 is backward compatible with .Net 1.1? Pin
Rob Graham24-Jan-07 10:23
Rob Graham24-Jan-07 10:23 
QuestionUsing BindingSource to edit stuff in a DataGridView Pin
Heavy Storm23-Jan-07 10:00
Heavy Storm23-Jan-07 10:00 
AnswerRe: Using BindingSource to edit stuff in a DataGridView Pin
Robert Rohde23-Jan-07 21:51
Robert Rohde23-Jan-07 21:51 
QuestionHandling Dispose when using unmanaged code Pin
AlexZieg7123-Jan-07 8:30
AlexZieg7123-Jan-07 8:30 
AnswerRe: Handling Dispose when using unmanaged code Pin
Dan Neely23-Jan-07 9:04
Dan Neely23-Jan-07 9:04 
AnswerRe: Handling Dispose when using unmanaged code Pin
Guffa23-Jan-07 11:37
Guffa23-Jan-07 11:37 
AlexZieg71 wrote:
Is it mandatory to call the "Dispose()"-method of an object that implements it or is the reserved memory be freed by the GC at a later time anyhow? If yes, why should I use IDisposable at all?


It's not really the memory that is the concern, but unmanaged resources. If you don't call Dispose, the object has to be finallized to free the resources, and that is not guranteed to take place at any specific time, or actually at all. If there are too many objects that needs finalizing when the application ends, it won't have time to finalize them all, so it will just kill them off anyway.

Also, calling Dispose makes collecting the object more efficient, as it then can be garbage collected directly. If you don't call Dispose, the object will go through one garbage collection, be placed in the queue to be finalized, be finalized, then go through a second garbage collection before it's finally freed.

If I use GC.SuppressFinalize(this) like in the example, and forget to "manually" dispose a used managed component in the Dispose-method, do I then have a memory leak?


You have a potential resource leak. If this unmanaged resource happens to be unmanaged memory, you have a potential memory leak.

If the component that you did not dispose uses any unmanaged resources, they are not guaranteed to be freed. Sometimes the garbage collector will manage to free it in time anyway before it becomes a problem, sometimes not.

---
Year happy = new Year(2007);

GeneralRe: Handling Dispose when using unmanaged code Pin
Tim Paaschen23-Jan-07 19:54
Tim Paaschen23-Jan-07 19:54 
GeneralRe: Handling Dispose when using unmanaged code Pin
Colin Angus Mackay24-Jan-07 22:16
Colin Angus Mackay24-Jan-07 22:16 
AnswerRe: Handling Dispose when using unmanaged code Pin
Scott Dorman28-Jan-07 6:53
professionalScott Dorman28-Jan-07 6:53 
QuestionCalculating Object Memmory Usage Pin
MikeMarq23-Jan-07 8:04
MikeMarq23-Jan-07 8:04 
AnswerRe: Calculating Object Memmory Usage Pin
Dave Kreskowiak23-Jan-07 8:44
mveDave Kreskowiak23-Jan-07 8:44 
GeneralRe: Calculating Object Memmory Usage Pin
MikeMarq24-Jan-07 9:53
MikeMarq24-Jan-07 9:53 
QuestionCan I customize the paper size and print a document directly Pin
indian14323-Jan-07 1:13
indian14323-Jan-07 1:13 
AnswerRe: Can I customize the paper size and print a document directly Pin
Dave Kreskowiak23-Jan-07 2:04
mveDave Kreskowiak23-Jan-07 2:04 
GeneralRe: Can I customize the paper size and print a document directly Pin
indian14323-Jan-07 2:14
indian14323-Jan-07 2:14 
GeneralRe: Can I customize the paper size and print a document directly Pin
Dave Kreskowiak23-Jan-07 5:31
mveDave Kreskowiak23-Jan-07 5:31 
GeneralRe: Can I customize the paper size and print a document directly Pin
indian14329-Jan-07 1:28
indian14329-Jan-07 1:28 
Questionwana buit an email clinet using a third party email server?? Pin
Saira Tanwir22-Jan-07 23:09
Saira Tanwir22-Jan-07 23:09 
AnswerRe: wana buit an email clinet using a third party email server?? Pin
indian14322-Jan-07 23:24
indian14322-Jan-07 23:24 
AnswerRe: wana buit an email clinet using a third party email server?? Pin
Guffa23-Jan-07 0:05
Guffa23-Jan-07 0:05 
AnswerRe: wana buit an email clinet using a third party email server?? Pin
indian14323-Jan-07 1:07
indian14323-Jan-07 1:07 
AnswerRe: wana buit an email clinet using a third party email server?? Pin
indian14323-Jan-07 22:05
indian14323-Jan-07 22:05 
Questionproblems with permission?? Pin
spell12822-Jan-07 14:50
spell12822-Jan-07 14:50 

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.