|
Is it suggested to dispose |
Replies: 4 comments 4 replies
|
I suspect it depends on how it is read and whether the underlying buffer is rented from a pool and needs to be returned. My rule of thumb is to always dispose of anything disposable, except for MemoryStream. |
|
It's always suggested to dispose when you are finally done with the request, by loading data into somewhere you manages. Disposing the response will also dispose the stream acquired from
The ways to cause leaks in managed world are very rare. Finalizer will clear heap objects that's not disposed. |
This is an implementation details, and thus could change in the future. |
|
So as a summary, it is a good practice, but nothing bad happens when the Dispose is call is forgotten. |
I suspect it depends on how it is read and whether the underlying buffer is rented from a pool and needs to be returned. My rule of thumb is to always dispose of anything disposable, except for MemoryStream.