Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fully managed shared memory .NET implementations? [closed]

I'm looking for free, fully-managed implementations of shared memory for .NET (P/Invoke is acceptable, mixed C++/CLI is not).

like image 915
em70 Avatar asked Jan 02 '11 21:01

em70


2 Answers

Well, the .NET framework is free, recommended. .NET 4.0 supports the System.IO.MemoryMappedFiles namespace classes. Shared memory is a fairly drastic impedance mismatch with the notion of a garbage collector, that's why it took a while. Unless you use pointers, copying from the GC heap to the MMF view is inevitable.

The other IPC mechanisms use shared memory too, it just isn't explicit since its built into the kernel. This all runs at roughly the same speed, a microsecond to setup the mapping and then just the bus bandwidth to do the memory-to-memory copy. Five gigabytes per second is the slowest you'll run into.

like image 116
Hans Passant Avatar answered Nov 16 '22 02:11

Hans Passant


Sounds like you are looking for Memory-Mapped Files, which are supported in the .NET 4.0 BCL.

Starting with the .NET Framework version 4, you can use managed code to access memory-mapped files in the same way that native Windows functions access memory-mapped files, as described in Managing Memory-Mapped Files in Win32 in the MSDN Library

like image 23
Richard Szalay Avatar answered Nov 16 '22 01:11

Richard Szalay