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 4254984
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:09:27+00:00 2026-05-21T05:09:27+00:00

I have, what I think, is a fairly trivial bit of javascript. If I

  • 0

I have, what I think, is a fairly trivial bit of javascript.
If I run this really fast, so that the situation is exacerbated, memory allocation in FireFox 4 keeps increasing. I tried this in chrome and memory seems to remain stable.

Is this a FF4 issue or do I have I constructed my JavaScript poorly?

Note no other JS files are loaded on the page. I am running FF in “safe mode” with all addons disabled. No other tabs are loaded.

<img id="heartbeat" name="heartbeat" src="/web/resources/graphics/greylight.png" />

    <script type="text/javascript">

        var hasTimedout = 1;
        var lastPollTime = new Date();;
        var maxDifference = 6000 * 2; //allows us to miss one poll of the data without showing anything bad

        function heartbeat()
        {
            var curTime = new Date();

            var diff = curTime.getTime() - lastPollTime.getTime();

            if (diff > maxDifference && hasTimedout == 0)
            {
                document.getElementById('heartbeat').src = '/web/resources/graphics/greylight.png';

                hasTimedout = 1;
            }
            else if (diff < maxDifference && hasTimedout == 1)
            {
                document.getElementById('heartbeat').src = '/web/resources/graphics/greenlight.png';

                hasTimedout = 0;
            }

            toggle_visibility('heartbeat');
        }

        function toggle_visibility(id) {
           var e = document.getElementById(id);
           if (e.style.display == 'block')
              e.style.display = 'none';
           else
              e.style.display = 'block';
        }

        setInterval("heartbeat()",20);    
    </script>
  • 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-21T05:09:28+00:00Added an answer on May 21, 2026 at 5:09 am

    Some info on Javascript garbage collection: SO Thread on JS GC

    Of particular interest (perhaps):

    • Use delete statements. Whenever you
      create an object using a new
      statement, pair it with a delete
      statement. This ensures that all of
      the memory associated with the
      object, including its property name,
      is available for garbage collection.
      The delete statement is discussed
      more in “Freeing Objects.”
    • Use the var keyword. Any variable
      created without the var keyword is
      created at the global scope and is
      never eligible for garbage
      collection, presenting the
      opportunity for a memory leak.

    I can only conclude that you should try pairing your object creation using the “new” keyword with delete statements and see if that makes a difference.

    Otherwise the code looks fine.

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

Sidebar

Related Questions

I think I have a basic understanding of this, but am hoping that someone
I am a bit new to R, but I think I have a fairly
I have what I think should be a fairly simple mapping issue, but not
I thought this would be fairly trivial but it's turned out be more difficult
I've got a, I think fairly easy question, but this is bugging me for
We have what I think is a fairly standard build process: 1. Developer: Check
I have a problem at hand which I'd think is fairly common amongst groups
I think I have a fairly basic question here. I'm not trying to waste
I'm trying to do something that I think should be fairly simple but I've
I've been Googling for it; but without any luck. I think this is fairly

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.