Click here to Skip to main content
15,913,685 members
Home / Discussions / C#
   

C#

 
GeneralRe: Dispose pattern in class derivation Pin
George_George16-Apr-08 3:47
George_George16-Apr-08 3:47 
GeneralRe: Dispose pattern in class derivation Pin
N a v a n e e t h16-Apr-08 3:59
N a v a n e e t h16-Apr-08 3:59 
GeneralRe: Dispose pattern in class derivation Pin
George_George16-Apr-08 4:08
George_George16-Apr-08 4:08 
GeneralRe: Dispose pattern in class derivation Pin
Scott Dorman19-Apr-08 8:25
professionalScott Dorman19-Apr-08 8:25 
GeneralRe: Dispose pattern in class derivation Pin
George_George19-Apr-08 21:11
George_George19-Apr-08 21:11 
GeneralRe: Dispose pattern in class derivation Pin
Scott Dorman20-Apr-08 5:01
professionalScott Dorman20-Apr-08 5:01 
GeneralRe: Dispose pattern in class derivation Pin
George_George20-Apr-08 19:06
George_George20-Apr-08 19:06 
GeneralRe: Dispose pattern in class derivation Pin
Scott Dorman22-Apr-08 17:02
professionalScott Dorman22-Apr-08 17:02 
Classes like StreamWriter are managed types. They wrap an unmanaged resource but also have the responsibility to clean up after themselves and dispose of those resources properly.

George_George wrote:
If my class has a StreamWriter member, and in Finalizer, I do not close it, and I rely on the Finalizer method of StreamWriter itself to close the native resource file handle. In this case, will there be any resource leak?


That's a good question. I believe, technically it isn't a resource leak, but you should probably consider it to be one. The idea here is that you want to acquire the resource as late as possible and free/release/dispose of it as early as possible. Relying on the finalizer to clean up the StreamWriter violates that concept and releases as late as possible.

Scott.

—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai

[Forum Guidelines] [Articles] [Blog]

GeneralRe: Dispose pattern in class derivation Pin
George_George22-Apr-08 17:15
George_George22-Apr-08 17:15 
Generalwriteprofilestring( ) Pin
Archana New to Dotnet16-Apr-08 0:35
Archana New to Dotnet16-Apr-08 0:35 
GeneralRe: writeprofilestring( ) Pin
Balaji.KJ16-Apr-08 0:58
Balaji.KJ16-Apr-08 0:58 
GeneralRe: writeprofilestring( ) Pin
#realJSOP16-Apr-08 1:39
professional#realJSOP16-Apr-08 1:39 
GeneralRe: writeprofilestring( ) Pin
Archana New to Dotnet16-Apr-08 6:54
Archana New to Dotnet16-Apr-08 6:54 
GeneralProblem with DOTNET RCW (Runtime Callable Wrapper) Method Pin
Balaji.KJ16-Apr-08 0:11
Balaji.KJ16-Apr-08 0:11 
GeneralRe: Problem with DOTNET RCW (Runtime Callable Wrapper) Method Pin
Vikram A Punathambekar16-Apr-08 1:03
Vikram A Punathambekar16-Apr-08 1:03 
GeneralRe: Problem with DOTNET RCW (Runtime Callable Wrapper) Method Pin
Balaji.KJ16-Apr-08 3:30
Balaji.KJ16-Apr-08 3:30 
GeneralRe: Problem with DOTNET RCW (Runtime Callable Wrapper) Method Pin
Dave Kreskowiak16-Apr-08 4:27
mveDave Kreskowiak16-Apr-08 4:27 
GeneralRe: Problem with DOTNET RCW (Runtime Callable Wrapper) Method Pin
Balaji.KJ16-Apr-08 18:54
Balaji.KJ16-Apr-08 18:54 
GeneralRe: Problem with DOTNET RCW (Runtime Callable Wrapper) Method Pin
Dave Kreskowiak17-Apr-08 1:28
mveDave Kreskowiak17-Apr-08 1:28 
Generalnot deleting a row in datagrid Pin
sarilee15-Apr-08 23:15
sarilee15-Apr-08 23:15 
GeneralRe: not deleting a row in datagrid Pin
J a a n s15-Apr-08 23:41
professionalJ a a n s15-Apr-08 23:41 
GeneralRe: not deleting a row in datagrid Pin
phannon8615-Apr-08 23:53
professionalphannon8615-Apr-08 23:53 
GeneralRe: not deleting a row in datagrid Pin
sarilee16-Apr-08 0:01
sarilee16-Apr-08 0:01 
GeneralRe: not deleting a row in datagrid Pin
r aa j16-Apr-08 0:09
r aa j16-Apr-08 0:09 
GeneralRe: not deleting a row in datagrid Pin
sarilee16-Apr-08 0:13
sarilee16-Apr-08 0:13 

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.