我知道该whos()函数将给出内存中所有对象的大小.这可能会很慢执行,并且有时会在某些对象上失败,从而使整个函数挂起.有没有办法获得特定对象的内存大小,类似于sys.getsizeof()Python中的函数?
amr*_*ods 17
varinfo()接受正则表达式来匹配对象名称,所以你可以使用类似的东西
x = rand(100, 100)
varinfo(r"x")
Run Code Online (Sandbox Code Playgroud)
获取信息x.对于以字节为单位的大小
Base.summarysize(x)
Run Code Online (Sandbox Code Playgroud)
编辑:最初这个答案是推荐的whos(),但是当@Plankalkül提及whos()已重命名时varinfo(),答案已相应更新.
你可以使用这个sizeof功能:
help?> sizeof
search: sizeof
sizeof(s::AbstractString)
The number of bytes in string s.
sizeof(T)
Size, in bytes, of the canonical binary representation of the given DataType T, if any.
julia> x = rand(100, 100);
julia> sizeof(x)
80000
Run Code Online (Sandbox Code Playgroud)