Learning notes for Ajax Memory leakage (Memory Leak)

Source: Internet
Author: User

In Ajax practice, Section 8.3.1 Describes memory leakage. Examples in the bookCodeIt is much more complicated than the simple sample code in section 4.3.4 of JavaScript advanced programming (version 2nd. The removepet sample code on page 242nd should be:

Person. prototype. removepet = function (petname) {var orphan = This. pets [petname]; this. pets [petname] = NULL; If (orphan. unassignowner) {orphan. unassignowner (this );}}

In this sample code, the local variable is: The line referenced by whiskers of a pet cat instance for Jim:

Jim. addpet (new CAT ("Whiskers ");

The global variable is: The line referenced by Jim's pet dog Fido:

VaR Fido = new dog ("Fido"); Jim. addpet (Fido );

Fido reference occupies valuable memory, which is a memory leakage problem. Until the reference is removed in step 2,Memory can be released later.

The last sentence in the last row of page 243rd is caused by the uplink. When does this "subsequent" mean? According to JavaScript advancedProgramThe content in Chapter 2nd of design (version 4th) refers to the next GC operation.

In the Ajax practice book, the first step of memory is released. Is the memory released by GC recycled? I still have doubts here, from opening the global variable space to removing the reference, this process can be described as a memory leakage problem in the book. But by the next GC operation, does this process count as a memory leak?

(End)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.