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.
本文探讨了Python如何处理非连接相关的IO操作,如哈希、集合等数据结构,并指出Python立即释放不再引用的内存。内存管理主要依赖于垃圾收集器,其设置可以调整。同时,讨论了操作系统如何决定将部分内存写入交换文件。文中以Redis作为例子,提到了一个Redis数据类型的Python包装器,以及如何评估不同硬件配置对程序性能的影响。
4080

被折叠的 条评论
为什么被折叠?



