In general, OpenAccess does not hold references more/longer than needed. For this to work you will need to obey the Dispose pattern. OpenAccess Context instances as well as the IObjectScope and Database implement it. This will ensure that persistent instances will be GC'able in time and memory is quickly available again.
However, in the original post the code to fill a large stream seems suboptimal: the target MemoryStream does not know how big it will be in the end, and so will need to resize often, which is an expensive operation. I think using stream.Length would be better:
Regards,
Thomas
Telerik
Check out the
latest announcement about Telerik Data Access vNext as a
powerful framework able to solve core development problems.