10
boblol
8y

Trying to learn C and thought a easy file copy was a good start. The program read the size of the file, reserved that size in memory, can copied data there and then to the new file. For some reason I never thought that the file might be bigger then available memory... Took a couple of BSOD to find that "bug".

Comments
  • 2
    How big was this file you were copying that it could swallow not only all your RAM but also all your Virtual Memory as well? (Assuming the OS was allocating your memory).
  • 0
    I would recommend reading the source file in chunks (e.g. 512 byte blocks) and writing the destination incrementally should be quick enough obviously play with the chunk size as mileage may vary.
  • 0
    @Wildgoose more than 4Gig on a 32 bit system? It's not uncommon. But even it it isn't, swapping mean you effectively copy the file back and forth from disk to memory.
Add Comment