As a Christmas gift I have written a small program in Java to calculate primes. My intention was to leave it on all night, calculating the next prime and writing it to a .txt file. In the morning I would kill the program and take the .txt file to my friend for Christmas.
Is there anything I should be worried about? Bear in mind that this is true beginner Ziggy you are talking to, not some smart error checking ASM guy.
EDIT More specifically, since I will be leaving this program on all night counting primes, is there any chance at all that I will encounter some kind of memory related error? Like, stacks crushing heaps or dogs and cats sleeping together?
EDIT even more specifically, is there a line of code I could put in to stop the printing of lines when the file's size is 4GB? Just to be safe?
EDIT: success: after leaving it on all night I got no more than 13 KB of primes, The highest I got was 22947217, which is like tens of thousands of primes. Success!
I would recommend sending an SMS message for each prime you calculate. Your friend would like that much better than a bunch of paper. Plus he can be updated much more often.
Only as to the size of the place you're storing the text file on disk.
And, if you're not writing it all right away, your memory + virtual memory.
If memory serves, FAT32 has a 4gig file limit size.
There's plenty of limits, though none of them are intrinsic to .txt files:
Somehow I doubt that when having your program run overnight, that the filesize will be a problem, considering that it will take longer to find primes as numbers get bigger. Just make sure you clean up or you might eat up all your RAM.
To answer your question: Theoretically, the filesystem restricts file size. However, a lot of text editors crash (vim does not) when loading big files (> 100 MB), because they try to fit it in one buffer.
To sum up, consider splitting up your files into chunks the weakest link (text editors) can handle.
Ziggy--
I love this: "not some smart error checking ASM guy." You are describing all of us!
Have plenty of disk space and write away! As previously mentioned, be sure the editor used to open your file can open very large files.
Happy holidays, true beginner Ziggy.