Expose server memory allocation functions

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Won't Do
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Integration
    • None
    • 3
    • TBD
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      As part of the barebones extensions API, we would like to expose memory allocation functions to extensions, which hook into the hosts's memory allocator. 

      The functions we'll need to expose as part of the API are:

      void* mongo_extension_alloc(size_t size);
      // If posix_memalign is true, posix_memalign behaviour is requested, otherwise behaves like aligned_alloc.
      void* mongo_extension_aligned_alloc(size_t size, size_t alignment, bool posix_memalign);
      
      void* mongo_extension_alloc_zeroed(size_t size);
      
      
      void* mongo_extension_dealloc(void* ptr);
      
      void* mongo_extension_aligned_dealloc(void* ptr, size_t size, size_t alignment);
      
      void* mongo_extension_realloc(void* ptr, size_t size);
      

      As part of this ticket, add these functions to the public API header, and implement them in the Host API using the host's allocator.
      We should implement unit tests for the above functions that verify we are correctly using the host's allocator.

      Idea: Do not link tcmalloc into the unit test target, verify that tcmalloc is used. There may be some debug functionality we can take advantage of to verify the memory blocks are coming from the host's allocator.

            Assignee:
            Unassigned
            Reporter:
            Santiago Roche
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: