Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sharing memory between two applications

Tags:

I have two different windows applications (two different people writing the code). One is Written in C++ and another one is in C#. I need some way how to share data in RAM between them. One must writes data and another one just reads the written data. What should I use to make it most effective and fast? Thanks.

like image 495
uniquepito Avatar asked Oct 25 '11 18:10

uniquepito


People also ask

Can two programs share memory?

If the two programs are running on the same machine, yes, you can have them share memory. You can do this with shared memory or memory-mapping the same file.

How can we share the memory between two processes?

The user just writes data to the process memory, and the operating systems dumps the data to the file. When two processes map the same file in memory, the memory that one process writes is seen by another process, so memory mapped files can be used as an interprocess communication mechanism.

What is shared memory with example?

In computer programming, shared memory is a method by which program processes can exchange data more quickly than by reading and writing using the regular operating system services. For example, a client process may have data to pass to a server process that the server process is to modify and return to the client.

What is shared memory in C#?

The SharedMemory library provides a set of C# classes that utilise a memory-mapped file for fast low-level inter-process communication (IPC) - specifically for sharing data between processes. * an implementation of a shared memory buffer for read/write.


2 Answers

You can use Memory Mapped Files.

Here is an article describing how to use them.

like image 131
Oded Avatar answered Dec 23 '22 08:12

Oded


You can use Named Pipes.

A named pipe is a named, one-way or duplex pipe for communication between the pipe server and one or more pipe clients. All instances of a named pipe share the same pipe name, but each instance has its own buffers and handles, and provides a separate conduit for client/server communication. The use of instances enables multiple pipe clients to use the same named pipe simultaneously.

Any process can access named pipes, subject to security checks, making named pipes an easy form of communication between related or unrelated processes.

like image 21
dtb Avatar answered Dec 23 '22 08:12

dtb