Is it possible to save the string somewhere in RAM instead, so that Hard Disk will not be engaged?
Yes, you can use one of a few interprocess communication methods. The choices includes
- sockets
- a memory mapped file
- shared memory
- pipes
Here is an example of using a file mapped to RAM with a call to mmap
.
A file mapped to RAM that can be modified by changing memory addresses directly instead of outputting to a stream, shares same benefits as a standard file.
Reading from and writing to a memory-mapped file avoids the extraneous copy that occurs when using the read( ) or write( ) system calls, where the data must be copied to and from a user-space buffer.