退出python时是否释放了内存_为什么CPython退出时没有释放所有内存?

我想说清楚,我没有看到这个问题描述的行为。相反,我的问题是关于问题本身的: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支持会对程序提出这一要求。在

这在我不知道的情况下有意义吗?这是什么意思?在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值