Mmap and hash table extension issue in glibc?

If this is Linux, you can use mremap If you write your hash table to be based on offsets and not absolute pointers, you can pass the MREMAP_MAYMOVE flag and never have to worry about allocation failures. (Well, until you exhaust your virtual memory, anyway. ).

If this is Linux, you can use mremap. If you write your hash table to be based on offsets and not absolute pointers, you can pass the MREMAP_MAYMOVE flag and never have to worry about allocation failures. (Well, until you exhaust your virtual memory, anyway.).

Thanks a lot 'Employed Russian' and 'Nemo' for the answers. I'll explore mremap(). Looks like if mmap is to malloc() then mremap is to realloc(), something I was needing desperately.

– Kapil Nov 1 at 13:18.

How reliable is this approach MAP_FIXED is very reliable: IF the memory you are asking for is available, the kernel will give it to you. What are the potential pitfalls The obvious one: something else may have gotten mmaped into the region you want to extend into, and you lose. If you are doing this for 64-bit process, you can mmap e.g.1TB of memory as your initial hash table allocation.So long as you don't actually access it, this mmap is effectively free (of cost), assuming you are doing MA_ANON mapping.

BTW, I hope you realize that you are re-inventing a bicycle here, as many existing solutions (such as tcmalloc and jemalloc) will already provide debugging facilities that are likely to be better that whatever you concoct yourself.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions