开发者

How does Python handle memory?

开发者 https://www.devze.com 2023-01-31 09:54 出处:网络
I\'ve been looking at a in-memory database -- and it got me thinking, how does Python handle IO that\'s not tied to a connection (and even data that 开发者_运维知识库is); for example, hashes, sets, et

I've been looking at a in-memory database -- and it got me thinking, how does Python handle IO that's not tied to a connection (and even data that 开发者_运维知识库is); for example, hashes, sets, etc.; is this a config somewhere, or is it dynamically managed based on resources; are there "easy" ways to view the effect resources are having on a real program, and simulate what the performance hit would be differing hardware setups?

NOTE: If it matters, Redis is the in-memory data store I'm looking at; there's an implementation of a wrapper for Redis datatypes so they mimic the datatypes found in Python.


Python allocates all memory that the application asks for. There is not much room for policy. The only issue is when to release memory. (C)Python immediately releases all memory that is not referenced anymore (this is also not tunable). Memory that is referenced only from itself (ie. cycles) are released by the garbage collector; this has tunable settings.

It is the operating system's decision to write some of the memory into the pagefile.


Not exactly what you're asking for, but Dowser is a Python tool for interactively browsing the memory usage of your running program. Very useful in understanding memory usage and allocation patterns.

http://www.aminus.net/wiki/Dowser

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号