简体   繁体   中英

Shared memory without memory-mapped files

Is it possible to share memory between two MFC C++ applications without using Memory mapped files ? Currently we are using this method to share structs, and it is too slow for our requirements. Is there a better way?

Are you sure it is the memory mapped files that are slow? The OS maps the same piece of RAM into both process spaces (when it's paged in.) Other culprits to performance issues could be mutexes and other synchronization primitives/volatile reads and cache invalidation to propagate concurrent changes to memory between processes.

You might try making changes locally to a non-shared region, and then bulk copying that, rather than repeatedly writing to the shared memory.

Other alternatives are message passing, RPC or DCOM, but I doubt these will be more performant, especially if the amount of data being transferred/referenced is large.

I would have thought that once you'd established the memory mapping (with the MapViewOfFile), that would be pretty fast.

Is your performance problem with actually setting up the mapped memory, rather than using it once it's set up?

If you do genuinely have a verified problem with the memory mapped files, this is another technique: http://msdn.microsoft.com/en-us/library/h90dkhs0%28VS.80%29.aspx (DLL shared memory segments), but I doubt it's really going to help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM