c++ - Very big persistent container for storing large amount of flags sets -


the problem following: have amount of words (let's 20m), each containing bits used flags; stored in single continuous binary file.

what access words in container like style, container_instance[i] allows me access i-th word. things more complicated, cannot store words in memory @ 1 time, have stored file , memory freed not used long period. simplify things whole sequence partitioned 1k fragments, need free , allocate such 1k blocks. memory should freed after time or after number of times container have been accessed.

thread safety in nice have. can protect externally.

the implementation have allocates blocks on demand (empty or read file if available; file not sparse, after last byte in file allocated empty) , not nicely done. not frees @ all, unused blocks remain in memory forever.

i started think nice looking solution , know whether elements stl or boosts can me build such container not engraving step step scratch?

i not expecting full solutions, rather pointing "you can use that that".

you can use mmap system call map file memory. can use pointer arithmetic buffer, access index not trouble.

mapped pages virutual , managed kernel, allowing save unused memory blocks , load/flush them @ transparently you. also, using madvise can enable optimisations.


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -