我想说清楚,我没有看到这个问题描述的行为。相反,我的问题是关于问题本身的:Why isn't all memory freed when CPython exits?
并给出以下答案:Objects referenced from the global namespaces of Python modules are
not always deallocated when Python exits. This may happen if there are
circular references. There are also certain bits of memory that are
allocated by the C library that are impossible to free (e.g. a tool
like Purify will complain about these). Python is, however, aggressive
about cleaning up memory on exit and does try to destroy every single
object.
If you want to force Python to delete certain things on deallocation
use the atexit module to run a function that will force those
deletions.
假设一个托管内存操作系统(Linux、Mac、Windows、GNU、BSD、Solaris…),这听起来完全是胡说八道。在
当一个程序退出时(不管是Python还是其他任何东西),它从操作系统请求的任何内存都会被释放(因为操作系统可以控制虚拟页表等)。这个程序不需要反分配或反构造任何东西(过去程序必须做的事情,正如人们使用cp得到{a2}时所强调的那样),但我不认为任何操作系统的python3支持会对程序提出这一要求。在
这在我不知道的情况下有意义吗?这是什么意思?在