Giter Site home page Giter Site logo

Comments (5)

daanx avatar daanx commented on September 12, 2024 1

Yes, mimalloc has mi_manage_os_memory for this purpose:

bool mi_manage_os_memory(void* start, size_t size, bool is_committed, bool is_large, bool is_zero, int numa_node);

This will add the memory area to the mimalloc arena's from which it will allocate its memory (use numa_node=-1 for no NUMA preference). There is no need for a specific heap, just mi_malloc will work. It is best if the area is as large as possible such that mimalloc can manage it most effectively with regard to fragmentation.

Hope this helps,
Daan

ps. There is also an extended api, mi_manage_os_memory_ex
to reserve "exclusive" memory that can only be used with heaps attached to such memory (mi_heap_new_in_arena) but I don't think that is what you are asking? (this is used for example to implement compressed pointers in the Koka language using a 4GiB exclusive area for language allocations)

from mimalloc.

CS0522 avatar CS0522 commented on September 12, 2024

Thanks very much for your help! It really does me a favor. mimalloc is very useful, and my project cannot be done without it.

from mimalloc.

gulmezmerve avatar gulmezmerve commented on September 12, 2024

@daanx I am a bit confused about how the mimalloc uses the process memory initially. As far as I know, when the process starts, it already reserves some memory area for the heap, and libc uses sbrk to extend.

But I can track mimalloc down, I understand that it does mmap do manage the memory, right?

Also, what is the alignment-requirement for the mimalloc?

from mimalloc.

daanx avatar daanx commented on September 12, 2024

Ah, mimalloc generally does not use sbrk (as that doesn't allow returning (purging) memory back to the OS), and we try to use mmap on most unix systems. See https://github.com/microsoft/mimalloc/blob/dev/src/prim/unix/prim.c for the primitives. Mimalloc allocates it's OS memory with 4MiB alignment (on 64-bit systems).

from mimalloc.

gulmezmerve avatar gulmezmerve commented on September 12, 2024

thank you for the clarification!

from mimalloc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.