如果我在REPL中玩,我为函数定义了几种不同的方法:
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忘记其中的一些或全部吗?
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:1Can I make Julia forget some or all of these?
最满意答案
总之,没有。
Julia没有模拟MATLAB的clear功能; 一旦在Julia会话中定义了名称(技术上,在模块Main ),它始终存在。
如果您关注内存使用情况,则始终可以使用内存较少的对象替换对象。 例如,如果A是您不再需要的千兆字节大小的数组,则可以使用A = 0释放内存。 内存将在下次垃圾收集器运行时释放; 你可以用gc()来强制这种情况发生。
( 来源 )
In short, no.
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.
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().
(source)
更多推荐
发布评论