Chapter 3: XMLHttpRequest Object 113
PART I
</form>
<br />
<hr />
<span id="countSpan">0</span> Created Divs
</body>
</html>
This simple example will begin to leak memory in versions of Internet Explorer 6 and
before, which can’t handle the circular references setup. You can see that in the capture
shown here from a memory leak tool for Internet Explorer appropriately called Drip:
From this simple example, you can see a small amount of memory being leaked each
time the button is clicked, but it does not seem too big of a deal because of the small amount
of memory leaked. However, imagine this on a larger scale. In Ajax applications, there may
be hundreds of event handlers. If each of these contains a circular reference, it can be enough
to crash the older versions of Internet Explorer. If you have Internet Explorer 6 or before
around and want to try crashing your browsers, simply adjust the number of <div> tags to
make 200,000 or more and you will likely crash regardless of the gigabytes of RAM you may
have.
Closures and memory leaks are actually the least of your worries. You’ll see in the
upcoming chapters that Ajax-style programming is going to introduce significant challenges
from dealing with network, security, and interface concerns you may have been able to
avoid before. So in the next chapter, let’s finish one more core topic, data formats, before we
vigorously tackle these challenges.