Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7855815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:29:56+00:00 2026-06-02T20:29:56+00:00

My question assumes you are creating a web page that will be displayed for

  • 0

My question assumes you are creating a web page that will be displayed for a “long time.” I’m curious as to what are some of the common gotchas that will cause memory leaks when using JQuery/JavaScript in such a scenario? For instance what happens in terms of memory when you call $.remove() on a collection of elements? Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T20:29:57+00:00Added an answer on June 2, 2026 at 8:29 pm

    JavaScript uses garbage collection to reclaim the memory occupied by
    strings, objects, arrays, and functions that are no longer in use.
    This frees you, the programmer, from having to explicitly deallocate
    memory yourself and is an important part of what makes JavaScript
    programming easier than, say, C programming.

    References : Check this for more and an answer on SO.

    Memory issues in event registering mechanism MDN

    var i;  
    var els = document.getElementsByTagName('*');  
    
    // Case 1  
    for(i=0 ; i<els.length ; i++){  
        els[i].addEventListener("click", function(e){/*do something*/}, false});  
    }  
    
    // Case 2  
    function processEvent(e){  
        /*do something*/  
    }  
    
    for(i=0 ; i<els.length ; i++){  
      els[i].addEventListener("click", processEvent, false});  
    }  
    

    In the first case, a new (anonymous) function is created at each loop turn. In the second case, the same previously declared function is used as an event handler. This results in smaller memory consumption. Moreover, in the first case, since no reference to the anonymous functions is kept, it is not possible to call element.removeEventListener because we do not have a reference to the handler, while in the second case, it’s possible to do

    myElement.removeEventListener("click", processEvent, false)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a mobile website that will include a page from which people can
This question assumes there's a blessed central repository that members of a team clone
For this question, let us assume that we will want to show the face
I'm creating an Android application that will register an Observer and listen for events,
I am creating a django-based site that will serve flash apps that occasionally access
My question assumes simple inserts into a table with no relevant relations. // various
I have a question regarding static function in php. let's assume that I have
This is a question about generic c++ event driven applications design. Lets assume that
(For the purposes of this question, let us assume that one is intentionally not
I'm creating a library for handling client caching over HTTP on a web server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.