mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-03 19:33:07 +03:00
reduce size of blocks returned to pool
This commit is contained in:
parent
44c2698f69
commit
db08235c05
|
@ -3473,7 +3473,7 @@ _set_blocks_max(PyObject* self, PyObject* args)
|
||||||
static PyObject*
|
static PyObject*
|
||||||
_clear_cache(PyObject* self, PyObject* args)
|
_clear_cache(PyObject* self, PyObject* args)
|
||||||
{
|
{
|
||||||
if (!PyArg_ParseTuple(args, ":_clear_cache"))
|
if (!PyArg_ParseTuple(args, ":clear_cache"))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ImagingMemoryClearCache(&ImagingDefaultArena, 0);
|
ImagingMemoryClearCache(&ImagingDefaultArena, 0);
|
||||||
|
|
|
@ -353,6 +353,11 @@ void
|
||||||
memory_return_block(ImagingMemoryArena arena, ImagingMemoryBlock block)
|
memory_return_block(ImagingMemoryArena arena, ImagingMemoryBlock block)
|
||||||
{
|
{
|
||||||
if (arena->blocks_cached < arena->blocks_max) {
|
if (arena->blocks_cached < arena->blocks_max) {
|
||||||
|
// Reduce block size
|
||||||
|
if (block.size > arena->block_size) {
|
||||||
|
block.size = arena->block_size;
|
||||||
|
block.ptr = realloc(block.ptr, arena->block_size);
|
||||||
|
}
|
||||||
arena->blocks[arena->blocks_cached] = block;
|
arena->blocks[arena->blocks_cached] = block;
|
||||||
arena->blocks_cached += 1;
|
arena->blocks_cached += 1;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user