我可以让茱莉亚(Julia)忘记REPL的方法吗 [英] Can I make Julia forget a method from the REPL

查看:122
本文介绍了我可以让茱莉亚(Julia)忘记REPL的方法吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在REPL中玩,并且为函数定义了几种不同的方法:

If I'm playing in the REPL and I've defined a few different methods for a function:

julia> methods(next)
# 3 methods for generic function "next":
next(i::BigInt) at none:1
next(i::Int64) at none:1
next(i) at none:1

我可以让茱莉亚(Julia)忘记其中一些或全部吗?

Can I make Julia forget some or all of these?

推荐答案

总之,不.

Julia没有MATLAB的clear函数的类似物;曾经一个名字 是在Julia会话中定义的(技术上,在模块Main中),它是 一直存在.

Julia does not have an analog of MATLAB’s clear function; once a name is defined in a Julia session (technically, in module Main), it is always present.

如果您关注内存使用情况,则始终可以将对象替换为 消耗更少内存的内存.例如,如果A是千兆字节大小 不再需要的数组,可以使用A = 0释放内存.这 内存将在下次垃圾回收器运行时释放;你 可以用gc()强制发生这种情况.

If memory usage is your concern, you can always replace objects with ones that consume less memory. For example, if A is a gigabyte-sized array that you no longer need, you can free the memory with A = 0. The memory will be released the next time the garbage collector runs; you can force this to happen with gc().

( 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆