gc.collect()==>python的强制垃圾收集机制(不建议使用强制回收,因为可能导致错误)
发布日期:2021-07-01 02:26:40 浏览次数:2 分类:技术文章

本文共 395 字,大约阅读时间需要 1 分钟。

def collect(*args, **kwargs): # real signature unknown

Run the garbage collector.

从内存中释放超出作用范围的变量,不在使用的对象等写此方法一般表示强制进行回收的,可能导致一些错误,建议不写为好

With no arguments, run a full collection.

The optional argument may be an integer specifying which generation to collect.

A ValueError is raised if the generation number is invalid. The number of unreachable objects is returned.

使用方法:

import gcgc.collect()

 

 

转载地址:https://mapengsen.blog.csdn.net/article/details/117905898 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:【pytorch】torch.cuda.empty_cache()==>释放缓存分配器当前持有的且未占用的缓存显存
下一篇:【PyTorch 】interpolate()==>上下采样函数

发表评论

最新留言

网站不错 人气很旺了 加油
[***.192.178.218]2024年04月21日 15时44分00秒