8000 gh-119802: Update memory management docs for free-threaded build by corona10 · Pull Request #124006 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-119802: Update memory management docs for free-threaded build #124006

8000 New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
gh-119802: Update memory management docs for free-threaded build
  • Loading branch information
corona10 committed Sep 12, 2024
commit 86efce6aa68bee59aa1b4a3502d7385ad4a5dbb5
16 changes: 10 additions & 6 deletions Doc/c-api/memory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,16 @@ All allocating functions belong to one of three different "domains" (see also
strategies and are optimized for different purposes. The specific details on
how every domain allocates memory or what internal functions each domain calls
is considered an implementation detail, but for debugging purposes a simplified
table can be found at :ref:`here <default-memory-allocators>`. There is no hard
requirement to use the memory returned by the allocation functions belonging to
a given domain for only the purposes hinted by that domain (although this is the
recommended practice). For example, one could use the memory returned by
:c:func:`PyMem_RawMalloc` for allocating Python objects or the memory returned
by :c:func:`PyObject_Malloc` for allocating memory for buffers.
table can be found at :ref:`here <default-memory-allocators>`. In the default build,
there is no hard requirement to use the memory returned by the allocation functions
belonging to a given domain for only the purposes hinted by that domain.
(although this is the recommended practice). For example, one could use the memory
returned by :c:func:`PyMem_RawMalloc` for allocating Python objects or the memory
returned by :c:func:`PyObject_Malloc` for allocating memory for buffers.
However, in the free-threaded build, Python objects must be allocated through :c:func:`PyObject_Malloc`.
Non-Python objects must not be allocated this function, for example,
it is currently acceptable to allocate buffers(non-Python objects) through :c:func:`PyObject_Malloc`;
that will no longer be allowed and buffers should instead be allocated through :c:func:`PyMem_Malloc`, :c:func:`PyMem_RawMalloc`, or :c:func:`malloc`..

The three allocation domains are:

Expand Down
Loading
0