-
Notifications
You must be signed in to change notification settings - Fork 229
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
Memory leak: unlike json.dumps
, orjson.dumps
does not release memory, resulting in the continuously growing memory usage
#483
Comments
json
, with orjson
memory is not released resulting in multiple time larger memory usagejson
, with orjson
memory is not released, resulting in a multiple times larger memory usage
json
, with orjson
memory is not released, resulting in a multiple times larger memory usagejson
, orjson
does not release memory, resulting in a much higher memory usage
json
, orjson
does not release memory, resulting in a much higher memory usagejson.dumps
, orjson.dumps
does not release memory, resulting in a much higher memory usage
Does |
Not stale. |
json.dumps
, orjson.dumps
does not release memory, resulting in a much higher memory usagejson.dumps
, orjson.dumps
does not release memory, resulting in the continuously growing memory usage
This is a true leak, in the sense that the returned bytes objects are much larger than they need to be. The bug is this line:
Here's a simpler reproducer: import orjson
import resource
lst = [orjson.dumps(digit) for _ in range(20_000) for digit in "1234567890"]
print(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1024, "MB") That program prints the maximum resident set size that the program reached. With |
And, to be clear, it's not a "true leak" in the sense that memory can never be reclaimed by the allocator. When the bytes object dies, the memory is reclaimed. The impact is only that the bytes object is much larger than it needs to be while it is alive, because no shrink-to-fit operation is happening. |
Not stale. |
Not stale. |
Search you tried in the issue tracker
"memory"
There is a range of different issues about memory usage, but all of them are either closed as "fixed" or are not strictly related to the current one.
Describe your issue
orjson
uses significantly more memory fororjson.dumps()
when I compare it to thejson
Python built-in library.I noticed that a peak memory usage in my application is larger when I use
orjson.dumps
(11 GiB withjson
VS 17 GiB withorjson
).Reproducible code example
how to run
results
orjson
json
results summary
With
orjson
the memory is growing continuously. The memory is not released.With
json
the memory is not growing. Variables from the initial dictionary are moved to a new list. The memory usage is persistent. This is the expected behavior.versions
orjson
3.10.33.10.4The text was updated successfully, but these errors were encountered: