and hunting memory leaks
@naugtur, 2020#coolstory
There's a live-leaking demo at the end.
You can follow along if you checkout this:
What to collect??
used to be called Hidden classes
Hidden Classes and Inline Caching in V8 (2015)var aBoy = { name: "Johny" },
aGirl = { name: "Sue" },
anAnimal = { name: "Garfield" };
aBoy = null;
//Johny can now be garbage-collected
aGirl = { name: "Lucy" };
//Sue can now be garbage-collected
aGirl.ownsAnimal = anAnimal
//we have a new reference to Garfield
anAnimal = null;
//a reference is removed, but it was not the only one
//Garfield can't be garbage-collected
delete
keyword does not free memorydelete
just slows you down (creates new Shape)null
doesn't remove the object, it changes the referenceWhat if I need thousands of objects for short periods of time? I'm implementing a minigun.
This really is only useful for things like particle animation or UI rendering libraries
@naugtur
http://naugtur.pl