Skip to content

Different buffers of bytes. Array, unmanaged heap and memory mapped file implementations.

License

Notifications You must be signed in to change notification settings

krivil/ByteBlock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ByteBlock

Different buffers of bytes. Array, unmanaged heap and memory mapped file implementations.

Implementations

All of them implement IByteBlock interface:

public interface IByteBlock : IDisposable {
    int Length { get; }
    Span<byte> AsSpan();
    UnmanagedMemoryStream AsStream();
}

Each block provide read/write span or stream.

Each call of AsSpan() or AsStream() produces new one.

NOTE: Due to Span<T> Length property being int, maximum size of any IByteBlock is int.MaxValue : 2 147 483 647 (0x7fffffff).

ArrayByteBlock

Backed by array of bytes.

Maximum length of byte[] in C# is 2 147 483 591 (0x7FFFFFC7)

HeapByteBlock

Buffer allocated in heap.

MemoryMappedByteBlock

Buffer persisted on file system.

Can be used for fast writing or reading of files smaller than int.MaxValue (2GiB - 1 byte).

About

Different buffers of bytes. Array, unmanaged heap and memory mapped file implementations.

Topics

Resources

License

Stars

Watchers

Forks

Languages