Skip to content

Comment on Google Closure: How not to write JavaScriptparent

Comments

> A memory leak is the inability of a program to free memory it has allocated.

Unexpected memoization/caching also counts as a memory leak. There are (unfortunately) a few places in Closure Library where unexpected memoization might cause a memory leak.

> Since js is garbage collected causing a memory leak involves creating a circular reference fooling the garbage collector into thinking that an object is still in use.

Browser environments are expected to handle circular references. They don't fool garbage collectors, except in old versions of IE when a circular reference crosses the JScript/DOM boundary.

Are you saying that the memory allocated by the memoizer is not recoverable e.g. won't be released until the browser is killed? If not then it is not a memory leak.

It's potentially recoverable, but stuck in some "private" object your JavaScript application will never bother to look at. It's still a memory leak.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.