How to do proper memory management with ZODB?

前端 未结 1 1402
小蘑菇
小蘑菇 2021-01-19 14:00

I read several ZODB tutorials but here is one thing I still don\'t get: How do you free memory that is already serialized (and committed) to the (say) FileStorage?

M

相关标签:
1条回答
  • 2021-01-19 14:52

    Creating savepoints and commiting the transaction already clears a lot of you memory.

    • You'll need to check what your ZODB cache parameters are set to, and tune these as necessary. The cache size parameter indicates the number of objects cached, not bytes, so you'll have to adjust this based on the size of your objects.

    • You can try and call .cacheMinimize() on the ZODB connection object, this explicitly deactivates any unmodified (or already committed) objects in the cache.

    Other than that, do note that even when Python frees objects from memory, the OS doesn't always reclaim that freed memory until it is needed for something else. OS-reported memory usage doesn't necessarily reflect actual memory requirements for a Python process.

    0 讨论(0)
提交回复
热议问题