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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T19:47:53+00:00 2026-05-18T19:47:53+00:00

I am coding an image gallery tonight and this led me to a philosophical

  • 0

I am coding an image gallery tonight and this led me to a philosophical question

I create a preloaded Image object and set an onload event for it

  ...  onmouseover = function() {
        preloadActive = true;
        imgPreload = new Image();

        imgPreload.onload = function() {
            preloadActive = false;
        }

        imgPreload.src = ...;
      }

Where imgPreload and preloadActive are global variables

Now imagine that a new onmouseover() fires out before onload() executes.

a line of code is run which creates a new image object, the old image object looses the last link and goes to Erebus, and is waiting for garbage collector to eat it.

The question goes here:
The old object instance is not destroyed immediately. Its onload event continues to live nobody knows for how long time? Do you have any cross-browser experience about that?

Thank you!

PS: I don’t worry about IE6


PPS: What happens if I have an object with setInterval timeout ID inside?

obj.someVar = setInterval(...)

Is setInterval stopped the very moment I execute

obj = {}

?

  • 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-18T19:47:54+00:00Added an answer on May 18, 2026 at 7:47 pm

    Well, for starters, global variables aren’t eligible for garbage collection (which is usually the cause of memory leak issues and is one of many reasons to avoid using global variables all together).

    Having said that, please read this article by Eric Lippert. It’s old, but I still think it is quite relevant.

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

Sidebar

Related Questions

I have this peice of coding which simply swaps an image when a link
There's this image on a page I'm coding which should be resized and horizontally
I'm working with Android currently, coding in Eclipse. I'm trying to set an image
So I have a random question when coding the image processing function that involves
Below is my coding where it would load the image when this Activity is
I'm coding a custom TableViewCell and I need to set a background image for
Coding in Delphi, attaching an OnKeyPress event handler to a TStringGrid: The OnKeyPress event
I would like to be able to add inline Image objects to Gallery in
I was coding a snake game, and i got an apple image to use
I'll try and make this question as brief as possible. I was wondering if

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.