Python memory releasing very slowly

2019-07-13 19:56发布

问题:

I am running hubble ( https://hubblestack.io/ ) on windows. When I put a lot of load on it, the memory consumption rises to about 1.5 GB. But when I stop the load, the program does not release the memory immediately. The program's memory consumption falls to about 200 MB after 1.5 hours ( on windows ). So here are my questions:

  1. Assuming that garbage collector is releasing the memory of this python program, why is it taking so much time. Shouldn't it be done is just a few seconds ( or minutes ) ?

  2. Why does't the GC free memory when the program is running ? GC should be running whenever #allocations - #deallocations > 700.

Any theory as to what might be happening ?

FYI, I noticed, that after a particular statement, the programs memory increases by 16 MB initially . An object of 250KB is created in that statement. After the programs memory has already increased a lot, the memory increases in bigger chunks 104 MB, 130MB, etc. around the same statement.

  1. Why is memory increasing in chunks ?