I have a program that generates a variable amount of data that it has to store to use later.
When should I choose to use mallod+realloc and when should I choose to use temporary files?
I have a program that generates a variable amount of data that it has
Share
Use temporary files if the size of your data is larger than the virtual address space size of your target system (2-3 gb on 32-bit hosts) or if it’s at least big enough that it would put serious resource strain on the system.
Otherwise use
malloc.If you go the route of temporary files, use the
tmpfilefunction to create them, since on good systems they will never have names in the filesystem and have no chance of getting left around if your program terminates abnormally. Most people do not like temp file cruft like Microsoft Office products tend to leave all over the place. 😉