Given the list of stored variables
Names@"`*"
is it possible to sort them by size in used memory?
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this community
checkMemory[] := Module[{u}, u = MemoryInUse[]*100/(MemoryInUse[] + MemoryAvailable[]) // N; Print["memory used= " <> ToString[u] <> "%"]; Grid[Reverse@ SortBy[({ByteCount[ToExpression[#1]]*100/MemoryAvailable[] // N, HoldForm[#1]} &) /@ Names["Global
*"], First]] ]` $\endgroup$OwnValues
, i.e. to differentiate true "variable" symbols not symbols that auto evaluate:SortBy[Names["`*"], ToExpression[#, StandardForm, Function[Null, ByteCount[HoldComplete[#] /. OwnValues[#]], HoldAllComplete]]
$\endgroup$SortBy[Names@"`*", ByteCount@ToExpression@# &]
$\endgroup$