Skip to main content
Typo
Source Link

Memory leaks assocaitedassociated with UI-building

Memory leaks assocaited with UI-building

Memory leaks associated with UI-building

update markdown to the new StackExchange standard
Source Link
Szabolcs
  • 238.9k
  • 32
  • 653
  • 1.3k

###Preamble

Preamble

###One subtle case with a memory leak

One subtle case with a memory leak

###Memory leaks assocaited with UI-building

Memory leaks assocaited with UI-building

###Monitoring symbols

Monitoring symbols

###Preamble

###One subtle case with a memory leak

###Memory leaks assocaited with UI-building

###Monitoring symbols

Preamble

One subtle case with a memory leak

Memory leaks assocaited with UI-building

Monitoring symbols

Fixed evaluation leak due to Options not holding the arguments
Source Link
Leonid Shifrin
  • 115.8k
  • 16
  • 341
  • 435
Clear[$globalProperties]; $globalProperties = {OwnValues, DownValues, SubValues, UpValues, NValues, FormatValues, Options, DefaultValues, Attributes, Messages}; ClearAll[getDefinitions]; SetAttributes[getDefinitions, HoldAllComplete]; getDefinitions[s_Symbol] := Flatten@Through[ Map[Function[propMap[ Function[ prop, (* Unevaluated needed here just for Options, which is not holding *)  Function[sym, prop[sym]prop[Unevaluated @ sym], HoldAll]]HoldAll] ], $globalProperties ][Unevaluated[s]] ]; ClearAll[symbolMemoryUsage]; symbolMemoryUsage[sname_String] := ToExpression[sname, InputForm, Function[s, ByteCount[getDefinitions[s]], HoldAllComplete] ]; ClearAll[heavySymbols]; heavySymbols[context_, sizeLim_: 10^6] := Pick[#, UnitStep[# - sizeLim] &@Map[symbolMemoryUsage, #], 1] &@ Names[context <> "*"]; 
Clear[$globalProperties]; $globalProperties = {OwnValues, DownValues, SubValues, UpValues, NValues, FormatValues, Options, DefaultValues, Attributes, Messages}; ClearAll[getDefinitions]; SetAttributes[getDefinitions, HoldAllComplete]; getDefinitions[s_Symbol] := Flatten@Through[ Map[Function[prop, Function[sym, prop[sym], HoldAll]], $globalProperties ][Unevaluated[s]] ]; ClearAll[symbolMemoryUsage]; symbolMemoryUsage[sname_String] := ToExpression[sname, InputForm, Function[s, ByteCount[getDefinitions[s]], HoldAllComplete] ]; ClearAll[heavySymbols]; heavySymbols[context_, sizeLim_: 10^6] := Pick[#, UnitStep[# - sizeLim] &@Map[symbolMemoryUsage, #], 1] &@ Names[context <> "*"]; 
Clear[$globalProperties]; $globalProperties = {OwnValues, DownValues, SubValues, UpValues, NValues, FormatValues, Options, DefaultValues, Attributes, Messages}; ClearAll[getDefinitions]; SetAttributes[getDefinitions, HoldAllComplete]; getDefinitions[s_Symbol] := Flatten@Through[ Map[ Function[ prop, (* Unevaluated needed here just for Options, which is not holding *)  Function[sym, prop[Unevaluated @ sym], HoldAll] ], $globalProperties ][Unevaluated[s]] ]; ClearAll[symbolMemoryUsage]; symbolMemoryUsage[sname_String] := ToExpression[sname, InputForm, Function[s, ByteCount[getDefinitions[s]], HoldAllComplete] ]; ClearAll[heavySymbols]; heavySymbols[context_, sizeLim_: 10^6] := Pick[#, UnitStep[# - sizeLim] &@Map[symbolMemoryUsage, #], 1] &@ Names[context <> "*"]; 
Added a section on UI-related memory leaks
Source Link
Leonid Shifrin
  • 115.8k
  • 16
  • 341
  • 435
Loading
Corrected a wrong statement
Source Link
Leonid Shifrin
  • 115.8k
  • 16
  • 341
  • 435
Loading
Source Link
Leonid Shifrin
  • 115.8k
  • 16
  • 341
  • 435
Loading