我可以让茱莉亚(Julia)忘记REPL的方法吗 [英] Can I make Julia forget a method from the 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 moduleMain
), 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()
.
( 查看全文