Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to perform zero-copying in .NET?

In Java I'd use the java.nio library and use FileChannel.transferTo() and FileChannel.transferFrom(). Is there something similar in (specifically) C# or am I going to have to load some unamanaged .dll from somewhere? Google has not been useful in this case.

Edit: I should note that I'm targeting .NET 3.5.

like image 814
ldam Avatar asked Mar 21 '13 16:03

ldam


1 Answers

I think the best performing equivalent might be UnmanagedMemoryStream.

This class supports access to unmanaged memory using the existing stream-based model and does not require that the contents in the unmanaged memory be copied to the heap.

Although I've never had cause to do this, so can't vouch for appropriateness of this class (or of using unmanaged code/memory in your scenario).

like image 74
Sepster Avatar answered Nov 11 '22 04:11

Sepster