Is it possible for an app to write to the hard drive? Instead of using normal memory?
Then delete what was stored on exit.
A few practical points to complement replies from and . Persisting data off the heap is straightforward, but real projects run into issues that simple examples often omit: permissions, concurrent access, partial writes, crash recovery, and secure removal.
Pick the right location and naming strategy. Use per-user or OS temp folders, create unique names to avoid collisions, and protect concurrent access with file locks or process coordination. Make writes atomic by writing to a unique temporary name and then renaming to the final path; on POSIX rename is atomic (see the man page) and calling fsync ensures the OS actually flushes the data to disk (see fsync docs).
Plan for crashes and orphaned files. Relying on a clean exit is fragile. On Windows there is a delete-on-close option you can use at creation time; on POSIX use secure temporary-creation APIs such as mkstemp. If the process can crash, add a startup sweep that removes stale files older than a safe threshold (timestamp check).
Handle security and storage-layer caveats. Simple deletion does not guarantee data is unrecoverable — SSDs, caching, and wear-leveling make secure erasure difficult. For sensitive ephemeral data prefer encryption and follow proven guidance (for example, NIST SP 800-88).
If performance matters, consider memory-backed filesystems (tmpfs) or memory-mapped files for large transient buffers. Those keep I/O fast and leave nothing on block devices after reboot. For cross-platform tasks, use the language or runtime temp APIs which wrap many of the patterns above.
Jump to Post— Ramy Mahrous 401Serialization as I think
Serialization as I think
Serialization would allow this.
Actually, there's lots of ways to do this. You could store your results in a text file, or in XML, something like that, then make sure you delete the file on the application's exit event.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.