i writing program needs traverse large 40gb binary file, have 16gb of physical ram. friend told me can use file mapping allievate problem. understand how create file mapping , reading file map handle, , how file mapping maps parts of file in persistent memory different chunks of virtual memory reading.
so if understanding correctly, can create buffer of 10gb, , read first 10gb of file buffer. when have read past 10gb mark on file, os fetch block automatically me, or have manually in code?
the functions linked aren't (directly) related file mapping. they're used regular file i/o.
to use traditional file i/o large file, described. open file, create buffer, , read chunk of file buffer. when need access different part of file, read different chunk buffer.
to use file mapping, use createfile, createfilemapping, , mapviewoffile. don't (directly) create buffer , read part of file it. instead, tell system want access range of file though range of memory addresses. reads , writes addresses turned file i/o operations behind scenes. in approach might still have work in chunks. if part of file need access not in range have mapped, can create view (and possibly close other one).
but note said address space, different ram. if you're building 64-bit windows, can try map entire 40 gb file address space. fact have 16 gb of ram won't stop you. there may other problems @ size, won't because of ram. if there other problems, you'll managing file in chunks before.
Comments
Post a Comment