1. 11
  1.  

  2. 3

    Author asked for more tricks on Twitter. Here’s a neat one for read-only memory someone gave him:

    http://notmysock.org/blog/2009/Jan/08/

    1. 1

      It occurs to me the eop_malloc demonstrated doesn’t ensure any alignment for the result (or rather, guarantees certain unalignments depending on the size requested).

      1. 1

        Lately I have been thinking how more of the virtual memory subsystem could be exposed to user space. When you do a mremap the pages will be added to or removed from the tail of the allocated region. Big memory regions are allocated by malloc with a mmap. Thanks to this two facts realloc of big memory regions will not copy data around, it will be a mremap. Now if you could insert pages in the middle you could easily do the equivalent of realloc-memmove for the page sized elements array.