Comments (5)
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.
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.
@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.
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.
thank you for the clarification!
from mimalloc.
Related Issues (20)
- Can't compile v2.1.6 tag on Ubuntu 22.04.LTS HOT 3
- malloc_good_size in overrides HOT 13
- Is it ok that `ld-linux-x86-64.so.2` `Scrt1.o` `crti.o` and `crtbeginS.o` is located before `mimalloc.o` in the linker commandline when static override malloc? HOT 1
- Inconsistent output naming of `mimalloc.dll` HOT 4
- 2.1.4: crash in mi_segment_try_purge during mi_process_done HOT 2
- Misplaced count size HOT 1
- mimalloc.o not available in vcpkg
- mimalloc-redirect for aarch64? HOT 1
- Cannot build mimalloc-2.1.7 with mingw32-8.5.0 HOT 1
- why mi_bin() return MI_BIN_HUGE if wsize > MI_MEDIUM_OBJ_WSIZE_MAX
- Is this a bug? segment-map.c uses an undefined constant MAX_UINT32 HOT 1
- memory decommit does not work with large pages HOT 2
- Extra compiler flags HOT 1
- Fix for GCC warning HOT 1
- Perf regression HOT 8
- Performance differences between Windows and Linux HOT 5
- control over non-api symbol declarations HOT 15
- minject compatibility with mimalloc.dll
- First class heap allocations from different threads HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mimalloc.