c - Creating a Database and want to write out to disk and not keep in RAM -
hi writing database in c , write out data hard drive , not have stored in ram anymore. there way this?
currently create big file , open such
fd = open("database.dat",o_creat | o_rdwr); hd = mmap(0, ssd_size, prot_read | prot_write, map_shared, fd, 0);
and write memory addresses have been mmapped , then
msync(dest,db_page_size, ms_sync);
where dest
in in mmaped region.
mmap() maps file in virtual address space, not load whole file ram. on 32 bit operating system database quite limited address space available, on 64 bit operating system mmap() should fine.
so, assuming os 64 bit, solution if fine: operating system manage mapping used pages in ram and, in case of memory pressure, pages wrote disk automatically.
Comments
Post a Comment