Kikobeats / js-mythbusters

:ghost: STHAP js, where is my perf?
https://mythbusters.js.org
MIT License
632 stars 68 forks source link

Should warn about memory leaks potentials #61

Closed GrosSacASac closed 6 years ago

GrosSacASac commented 6 years ago

https://mythbusters.js.org/#/v8-tips/freeing-memory

using

var foo = { bar: 'hello world' }
foo.bar = undefined // Efficient way (good)

can lead to memory leaks because foo keeps the string key "bar" stored potentially forever. Can happen when objects are used as maps.

Kikobeats commented 6 years ago

not sure if I understand you, the point here is

foo.bar = undefined // Efficient way (good)

instead of

delete foo.bar // Inefficient way (bad)

you keep bar reference in the object, but this is less aggresive than delete the key for the garbage collector.