justinstenning / SharedMemory

C# shared memory classes for sharing data between processes (Array, Buffer and Circular Buffer)
https://www.nuget.org/packages/SharedMemory
Other
566 stars 118 forks source link

ArraySlice implementation #17

Closed kasajian closed 8 years ago

kasajian commented 8 years ago

Same as https://github.com/spazzarama/SharedMemory/pull/16 but to Dev branch.

This is an ArraySlice implementation based on .NET's own ArraySegment. It's been modified to support any IList rather than require an array. The benefit is that it can now work with Shared Array because it supports IList.

ArraySlice implements IList, so to an application, it can easily be replaced where you typically would use an array.

The benefit of ArraySlice is that you can create a single large array and then smaller arrays refer to parts of the larger array. One advantage of this is that if you have a lot of small arrays, you don't incur the overhead of creating a Shared Array which has the overhead of its own memory mapped file. Every SharedArray takes 500-600 bytes (on 64-bit) regardless of the actual size of the array.

Related to: https://github.com/spazzarama/SharedMemory/issues/15