0

I'm wanting to use memory-mapped IO to establish communications between two applications of mine (primarily to avoid the problem of sockets tending to leak to other computers on the network). However, one issue I am concerned about is storage space: as I continue writing commands to the file, that file is only going to get larger. Granted, most of the commands are short and it would take a few days of constant runtime for it to become a problem, but I would like to avoid it all the same. Is there a good way for me to periodically clear the file of "old" messages that my recipient application has already read, thus reclaiming disc storage space?

MusicMan
  • 134
  • 9
  • Isn't it up to you how you organize the file content and its modification? For instance, could you use another file, where the recipient application will inform the producer application about the consumed messages, and thus the producer application could use those portions of the file again for fresh data? – Palo Aug 13 '21 at 11:04
  • That did occure to me. That, or I could use the first few bytes of the file to manage the counters (randomly jumping around in the file isn't too expensive as long as I'm not triggering page swaps, right?) I just wanted to make sure I wasn't missing out on some alternative solutions. – MusicMan Aug 13 '21 at 11:10
  • 1
    You may be interested in this answer https://stackoverflow.com/a/30292086/3656904 – talex Aug 13 '21 at 12:45
  • That looks like what I need. The author does say it may not work on non-Unix systems, but I don't really see what would preclude that. I'll look into testing that. – MusicMan Aug 13 '21 at 14:28

0 Answers0