Skip to content

Memory leak on macOS #773

@janbridley

Description

@janbridley

The readline module included with UV python builds leaks memory, resulting in unexpected behavior for all inheriting packages (including Pytest most notably).

To reproduce, create a uv venv on macOS with python versions 3.10, 3.11, 3.12, or 3.13. Then, run a leak checker on import readline

> sudo leaks --atExit -- python -c "import readline" | grep bytes

Process 5364: 1 leak for 16 total leaked bytes.
    1 (16 bytes) ROOT LEAK: <non-object from libedit.3.dylib 0x149805d80> [16]

Running the (roughly) equivalent command on linux appears not to leak memory:

> valgrind --leak-check=full python -c "import readline" 
==2484992== LEAK SUMMARY:
==2484992==    definitely lost: 0 bytes in 0 blocks
==2484992==    indirectly lost: 0 bytes in 0 blocks
==2484992==      possibly lost: 0 bytes in 0 blocks
==2484992==    still reachable: 500,336 bytes in 199 blocks
==2484992==         suppressed: 0 bytes in 0 blocks

This only seems to be the case in UV python distros - I can confirm that homebrew python versions do not leak memory.

See pytest-dev/pytest#13636 for the original reference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions