diff options
author | Dino Viehland <dinoviehland@fb.com> | 2023-10-30 15:43:11 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-30 15:43:11 (GMT) |
commit | 05f2f0ac92afa560315eb66fd6576683c7f69e2d (patch) | |
tree | a6a4746103a67f06f04ff6df9f290f0305ff9dd5 /Include/internal/pycore_mimalloc.h | |
parent | 4ebf2fae9664a4042511059627f44d46dceb2e09 (diff) | |
download | cpython-05f2f0ac92afa560315eb66fd6576683c7f69e2d.zip cpython-05f2f0ac92afa560315eb66fd6576683c7f69e2d.tar.gz cpython-05f2f0ac92afa560315eb66fd6576683c7f69e2d.tar.bz2 |
gh-90815: Add mimalloc memory allocator (#109914)
* Add mimalloc v2.12
Modified src/alloc.c to remove include of alloc-override.c and not
compile new handler.
Did not include the following files:
- include/mimalloc-new-delete.h
- include/mimalloc-override.h
- src/alloc-override-osx.c
- src/alloc-override.c
- src/static.c
- src/region.c
mimalloc is thread safe and shares a single heap across all runtimes,
therefore finalization and getting global allocated blocks across all
runtimes is different.
* mimalloc: minimal changes for use in Python:
- remove debug spam for freeing large allocations
- use same bytes (0xDD) for freed allocations in CPython and mimalloc
This is important for the test_capi debug memory tests
* Don't export mimalloc symbol in libpython.
* Enable mimalloc as Python allocator option.
* Add mimalloc MIT license.
* Log mimalloc in Lib/test/pythoninfo.py.
* Document new mimalloc support.
* Use macro defs for exports as done in:
https://github.com/python/cpython/pull/31164/
Co-authored-by: Sam Gross <colesbury@gmail.com>
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Include/internal/pycore_mimalloc.h')
-rw-r--r-- | Include/internal/pycore_mimalloc.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Include/internal/pycore_mimalloc.h b/Include/internal/pycore_mimalloc.h new file mode 100644 index 0000000..c29dc82 --- /dev/null +++ b/Include/internal/pycore_mimalloc.h @@ -0,0 +1,19 @@ +#ifndef Py_INTERNAL_MIMALLOC_H +#define Py_INTERNAL_MIMALLOC_H + +#ifndef Py_BUILD_CORE +# error "this header requires Py_BUILD_CORE define" +#endif + +#if defined(MIMALLOC_H) || defined(MIMALLOC_TYPES_H) +# error "pycore_mimalloc.h must be included before mimalloc.h" +#endif + +#include "pycore_pymem.h" +#define MI_DEBUG_UNINIT PYMEM_CLEANBYTE +#define MI_DEBUG_FREED PYMEM_DEADBYTE +#define MI_DEBUG_PADDING PYMEM_FORBIDDENBYTE + +#include "mimalloc.h" + +#endif // Py_INTERNAL_MIMALLOC_H |