Skip to content

Pillow support for cyclic garbage collection #7011

Answered by wiredfool
Lucas-C asked this question in Q&A
Discussion options

You must be logged in to vote

As far as I recall, we don't have any possible cycles in our C python objects.

There are a couple of bits that might make it a little difficult to reason about the memory usage --

Pillow uses a cached memory allocator so that we're not malloc/freeing for every image. This can lead to memory growth proportional to the max size of all concurrent images in the process. This is in Storage.c: https://github.com/python-pillow/Pillow/blob/main/src/libImaging/Storage.c#L320 There are a couple of functions exposed on the internal im object, get_stats https://github.com/python-pillow/Pillow/blob/main/src/_imaging.c#L4159 . These might help you quantify how much memory is in the cached allocator.

Va…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@Lucas-C
Comment options

Comment options

You must be logged in to vote
3 replies
@radarhere
Comment options

@Lucas-C
Comment options

@wiredfool
Comment options

Answer selected by Lucas-C
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
3 participants