I want to implement a mail download function for an own POP3 client (please no shoutings "use a library" as that's not a convenient solution for me) for linux. The mails should be downloaded and then directly reprocessed by another program.
Usually mails have quite different sizes. Some consist of just 3 or 4 kb, some take up even 20 megs or more. The program I write, however, should be capable of running as a demon on older machines (e.g. 166mhz pentium I with 64 mb memory) as well.
How should I store the emails fromt he moment they're downloaded till the moment they are processed and not needed anymore?
Should I use the memory (i.e. the heap) or would it be better to use temporary files?
If I use temporary files but will need to use string functions on the content of the mail, is mapped memory (mmap()) the solution I want to access the file?
And how much memory would be suitable to allocate, for example for smaller mails?
My solutions so far:
I thought of setting a split value at like 128kbyte - every mail staying below this limit I will process directly using the memory, the other mails I'll first save into temporary files and will then use mmap() to process them part by part.
I'd be glad if someone more experienced on memory and swap modes issues than me could help!