Skip to content
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

Fix memory leak in Raw.copy(). #709

Merged
merged 2 commits into from
Oct 13, 2024
Merged

Fix memory leak in Raw.copy(). #709

merged 2 commits into from
Oct 13, 2024

Commits on Oct 13, 2024

  1. Fix memory leak in Raw.copy().

    Raw_New borrows a reference to its PyBytesObject argument, so Raw_Copy must
    still dispose of it.
    
    The following is a minimal repro for this issue:
    
    import msgspec
    
    DECODER = msgspec.msgpack.Decoder(type=msgspec.Raw)
    PAYLOAD = b"\xda\xff\xff" + (65535 * b"\0") # array of 65535 zeros
    
    for _ in range(1000000):
      raw = DECODER.decode(PAYLOAD)
      raw.copy()
    tjgq authored and jcrist committed Oct 13, 2024
    Configuration menu
    Copy the full SHA
    d2a8288 View commit details
    Browse the repository at this point in the history
  2. Add test for raw copy memleak

    jcrist committed Oct 13, 2024
    Configuration menu
    Copy the full SHA
    15a62bf View commit details
    Browse the repository at this point in the history