Is there an open source implementation of MemoryStream that doesn't use continuous memory?

Like GuyFawkes , I would like to use a MemoryStream to store a lot of data, but I continue to run into memory exceptions.
TomTom's answer is what I would like to do - use an implementation that does not require a continuous block - but I wonder if there is already a free implementation so that I can write it myself?

Does anyone know of a good, free reimplementation of MemoryStream that can handle large threads?

EDIT:

The MemoryMappedFile solution is very interesting, and I will remember it for other projects, however, as Henk says, it is too far from the abstraction that MemoryStream aims for. In particular, the requirement of known capacity.
The data that the replacement should handle will in some cases be very large, but in others relatively small (and we do not know what will be until it is too late;)); in addition, many instances of the class will exist simultaneously. Ultimately, the work required to use MemoryMappedFiles (to determine the appropriate size for each of them) will be equivalent to the work associated with implementing the TomTom solution.

+8
c # memorystream
source share
3 answers

Here is my implementation, if anyone needs it; I will leave this question open in case someone still answers better.

http://www.codeproject.com/Articles/348590/A-replacement-for-MemoryStream

+3
source share

You will create a MemoryMappedFile without a file, i.e. one that lives in system memory. The DelayAllocatePages parameter delays the allocation until memory is actually needed. However, you need to specify the maximum bandwidth. Use the CreateViewStream Method to create the stream.

+1
source share

Not exactly a re-implementation of MemoryStream, but consider whether you can use the Mapped File for your requirement.

Memory mapped files can solve many of the classes of problems that large memory buffers can solve, are very efficient and are supported directly by .NET.

0
source share

All Articles