這裏是我的內存使用情況的分析解決方案:
myByteCount[symbolName_String] :=
Replace[ToHeldExpression[symbolName],
Hold[x__] :>
If[MemberQ[Attributes[x], Protected | ReadProtected],
Sequence @@ {}, {ByteCount[
Through[{OwnValues, DownValues, UpValues, SubValues,
DefaultValues, FormatValues, NValues}[[email protected],
Sort -> False]]], symbolName}]];
With[{listing = myByteCount /@ Names[]},
Labeled[Grid[[email protected][Sort[listing], -100], Frame -> True,
Alignment -> Left],
Column[{Style[
"ByteCount for symbols without attributes Protected and \
ReadProtected in all contexts", 16, FontFamily -> "Times"],
Style[[email protected]{"Total: ", Total[listing[[All, 1]]], " bytes for ",
Length[listing], " symbols"}, Bold]}, Center, 1.5], Top]]
評價高於下表給出了:
@Alexy,你可以指向一個示例代碼/演示? – 2014-07-12 00:14:22
@myaccount_ram示例:http://stackoverflow.com/a/5017071/590388 – 2014-07-12 03:15:24