what if SomeObject has some references to elements in a webpage plus some event handlers attached to them ?
cheers, jgabios http://bash.editia.info On Tue, Dec 7, 2010 at 1:19 PM, Tim Down <[email protected]> wrote: > 2010/12/7 Adrian Olaru <[email protected]>: >> Hi guys, >> I have this code: >> var a; >> function init() { >> a = new SomeObject("one"); >> a.doSomething(); >> a = new SomeObject("two"); >> a.doSomething(); >> } >> init(); >> a = null; >> What happens with the first object created and assigned to a? It's this an >> example of memory leaking, or will be garbage collected? >> Now, I know about garbage collection and how is implemented in browser >> (mark-and-sweep vs ref count (ie) ), but still, I wanna be sure. >> Thanks. > > It will be garbage collected. No memory leaks. > > Tim > > _______________________________________________ > JSMentors mailing list > [email protected] > http://jsmentors.com/mailman/listinfo/jsmentors_jsmentors.com > _______________________________________________ JSMentors mailing list [email protected] http://jsmentors.com/mailman/listinfo/jsmentors_jsmentors.com
