Reputation: 6278
In the following scenario I want to return just a string because that's what the spec says but to do that I have to return a stream and I just want to make sure than I don't keep too many streams around for too long. The method looks like:
[WebGet(BodyStyle = WebMessageBodyStyle.Bare,
RequestFormat = WebMessageFormat.Xml,
ResponseFormat = WebMessageFormat.Xml,
UriTemplate = "someuri/{parameter}")]
[OperationContract]
public Stream FooBar(string parameter)
{
byte[] bytes = Encoding.UTF8.GetBytes("some string");
return new MemoryStream(bytes);
}
Does anyone know when this resource is released?
Upvotes: 3
Views: 3070
Reputation: 754778
I've been doing some research and found a few interesting articles on the topic:
Hope that might be helpful!
Upvotes: 4
Reputation: 273314
I would think by the GC, as for a normal object: when all references to it have gone.
And that is not bad, MemoryStream does implement IDisposable but doesn't really need it.
Upvotes: 1