Quantcast
Channel: The Old New Thing
Viewing all articles
Browse latest Browse all 24428

re: The somewhat misguided question of whether MapViewOfFile or WriteProcessMemory is faster

$
0
0

@JM "Locally they're faster than TCP/IP"

They both run equally fast on the same machine. Connecting to localhost doesn't put packets on the network donchaknow. ...

I think something that is worth mentioning is that shared memory is a BAD choice for IPC unless you REALLY know what you're doing. You have to be really careful about Time-of-check Time-of-use bugs since when you're reading the memory in the server there's nothing to stop a malicious program on the other side writing to that data. You have to manually buffer the content to avoid these TOCTOU bugs.

If you use a named pipe or a socket, the bytes you've read in aren't subject to those race-conditions, and whilst you're waiting on the pipe or the socket the guy on the other side gets a short scheduler boost, so using those makes your programs more reliable AND faster; and you don't need to allocate funky memory sections which consume lots of Virtual Memory in your process to do it :)


Viewing all articles
Browse latest Browse all 24428

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>