Leak Free Javascript Closures

I haven't read this really, but it's in the queue for such a long time I might as well pass it along...

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.


This is an ugly hack to get around the fact that some browsers don't do a real GC and don't use weak references when dealing with event handlers.


As far as I remember, Mozilla uses Boehm's garbage-collector for JS. How this works in the detail, I have no idea.


As far as I remember from my experiments with google maps, neither Mozilla nor IE collect significant amounts of garbage.


the fact that some browsers don't do a real GC

Internet Explorer uses a mark-and-sweep garbage collector for its JS engine. The implementation may be crude, but it is as real as any. Keep in mind that Ajax was just a cleaning product when IE6 was first shipped five years ago.

Not at all.

"Ajax" has been in Internet Explorer for several versions. It didn't have the cutesy name in those days, but look for documentation about DHTML or Dynamic HTML. The technology and even JavaScript objects that make Ajax work were a Microsoft innovation.

If something doesn't have a

If something doesn't have a name, does it exist?

Yes, as anyone who codes in

Yes, as anyone who codes in pointless^Wpoint-free style knows!




Ajax didn't exist until Jesse James Garrett gave the name to a collection of technologies that had been around for years. Ofcourse many people (like me) that had been working with these technologies for years where a little offended.

But apparently Ajax needed to be named. Either to become mainstream or because it had become mainstream.

My point is that before mr Garret invented the term Ajax, most applications didn't use the browser to it's full extend and memory leaks wheren't a real issue.

I was joking...

I guess everyone knows already about the history of Ajax (and DHTML, and xmlhttprequest etc.)

You guys are doing cool work for quite awhile. I think we even linked to it a couple of times.

No need to be upset ;-)

RE: Not at all.

I'm not upset, I was just trying to explain my cleaning product remark to nat, who apparently shares my (initial) frustration about the term Ajax. :)

You guys are doing cool work for quite awhile. I think we even linked to it a couple of times.

Thanks! And I think you did.

I share a little of your

I share a little of your frustration :-)

In 2000 I was using DHTML on a PocketPC and Ruby on the server side to deliver dynamic apps over wireless. If only I had invented a cutesy name for it I'd be rich by now!

What frustrates me is that so many developers don't evaluate the technologies they have and choose appropriate designs for the front end and back end parts of their system. Instead they wait for a buzzword and then try to be "compliant".

The most depressing thing I've ever read about our industry is the story of the term "POJO".


Are you referring to Martin's omission of the prior art from the C/C++ world? I suppose POJO might have been an independent reinvention-with-a-twist from the "Plain Old Telephone System" and the C++ standards committee's "Plain Old Data Structures", but I'm guessing there was at least a bit of (possibly unconscious) inspiration that came from those earlier formations. See, e.g., the third comment here.

POJO Risin'

I think the real problem is the lack of specific terms for important but basic concepts. The story of POJO is the story of how an important hole in our lexicon was plugged, which is a good thing, and shouldn't be depressing. Many people used POJOs and Ajax before they had those names — having the name just made it easier to explain it to other people, and levelled the terminological playing field relative to entity beans etc.