That's it! Everything else might leak and it will go undetected by the tool. Here is an example:
function DripDetectable()
{
var container = document.getElementById("container");
for (var i = 0; i < 100; i++)
{
var link = document.createElement("A");
link.innerHTML = "test1";
link.circular = link;
container.appendChild(link);
}
}
This function will create 100 links that will leak because of the deliberate circular reference (the circular expando property points to the link itself). Drip will detect those, because they were created by calling document.createElement(...).
Here is something completely different:
function DripInvisible()
{
var container = document.getElementById("container");
for (var i = 0; i < 100; i++)
{
var linkText = "<a id='link" + i + "'>test2</a>";
container.innerHTML += linkText;
var link = document.getElementById("link" + i);
link.circular = link;
}
}
This function creates another 100 of links, but this time it uses string concatenation and innerHTML to create the links. The links have the same circular reference and really do leak. The memory usage of iexplore.exe keeps going up when you refresh the page. Drip, sadly, reports nothing.
Yes, I know innerHTML is a nonstandard property and should be avoided, but it's so damn convenient, and there are those times that you just can't implement something without it. We have two options right now: decrease the innerHTML usage or augment the Drip tool, so that it detects those leaks. Digging through a COM-infested C++ project (oh ATL and MFC too) does not make me happy, so I'll research the first option.
I will keep you posted with any workarounds that we find and possibly other funny ways to leak and annoy your customers :-). Good luck with your leaks.
Stefan Rahnev (@StDiR) is Product Manager for Telerik Kendo UI living in Sofia, Bulgaria. He has been working for the company since 2005, when he started out as a regular support officer. His next steps at Telerik took him through the positions of Technical Support Director, co-team leader in one of the ASP.NET AJAX teams and unit manager for UI for ASP.NET AJAX and Kendo UI. Stefan’s main interests are web development, agile processes planning and management, client services and psychology.