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

  • Home
  • SEARCH
  • 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 6142377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:22:41+00:00 2026-05-23T18:22:41+00:00

Is it possible freeing the browser memory from JavaScript objects? I am designing the

  • 0

Is it possible freeing the browser memory from JavaScript objects?

I am designing the asynchronous navigation process of a web app, in which page parts are loaded through AJAX requests together with their necessary components (CSS, JS, images etc): I guess that without a proper scripting, a long usage of the app would load many different objects causing a brutal memory growth.

As I could imagine, the removal of a script tag from the DOM only removes the DOM node, not the objects and functions it defines, which remains loaded into the browser memory.
(A similar test: Should a "script" tag be allowed to remove itself?).

I also tried to test the browser behaviour while setting a variable as a big string and then overwriting it:

<html>
<head>
    <title>JS memory test</title>
    <script type="text/javascript">
    function allocate() {
        window.x = '';
        var s = 'abcdefghijklmnopqrstuvwxyz0123456789-';

        for (var i = 0; i < 1000000; ++i) {
            window.x += 'hello' + i + s;
        }
        alert('allocated');
    }

    function free() {
        window.x = '';
        alert('freed');
    }
    </script>
</head>
<body>
    <input type="button" value="Allocate" onclick="javascript:allocate();" />
    <input type="button" value="Free" onclick="javascript:free();" />
</body>
</html>

Data from the Chrome task manager:

page weight when loaded:
    5736 KB
page weight after having set the variable:
    81720 KB
page weight after having the variable reset:
    81740 KB

It strikes me since I thought the JS garbage collector throws away the old variable value, since it is overwritten from the new assigned value.
Firefox has not a single-task-tab management, so there’s not a similar process monitor like in Chrome, but the global memory usage seems that it behaves almost like Chrome.

Is there some wrong assumption?

Can somebody provide suggestions about effective programming practices or useful resources to read?

Thanks a lot.

  • 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-05-23T18:22:42+00:00Added an answer on May 23, 2026 at 6:22 pm

    You have no direct access to memory management features. The best you can do is remove references to objects so that they are available for garbage collection, which will run from time to time as the browser sees fit.

    From time to time certain browsers exhibit memory leaks, there are strategies to reduce them but usually for specific cases (e.g. the infamous IE circular reference leak, which has been fixed, even in updated versions of IE 6, as far as I know).

    It’s probably not worth worrying about unless you find you have issues. Deal with it then.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How do you send email from a Java app using Gmail? How
Possible Duplicate: ( POD )freeing memory : is delete[] equal to delete ? Does
Possible Duplicate: Is freeing allocated memory needed when exiting a program in C I
Possible Duplicates: What's better at freeing memory with PHP: unset() or $var = null
Possible Duplicate: How to profile and and get Javascript performance I have a page
Possible Duplicate: NAnt or MSBuild, which one to choose and when? What is the
Possible Duplicate: JavaScript: var functionName = function() {} vs function functionName() {} What's the
Possible Duplicate: Singleton: How should it be used Following on from Ewan Makepeace 's
I'm designing a program to solve solitaire games in the highest-scoring way possible. The
Possible Duplicate: Find out the instance id from within an ec2 machine I am

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.