Memory leak with images?
-
- Guest
Memory leak with images?
Hi
on my webpage I am refreshing images with javascript, and firefox is using more and more memory, especially on a Mac. Both my winxp and my mac run the most recent firefox version (2.0.0.2). This makes my page use a lot of memory.
Any help would be greatly appreciated!
Markus
on my webpage I am refreshing images with javascript, and firefox is using more and more memory, especially on a Mac. Both my winxp and my mac run the most recent firefox version (2.0.0.2). This makes my page use a lot of memory.
Any help would be greatly appreciated!
Markus
-
- Posts: 3483
- Joined: November 4th, 2002, 10:47 pm
- Location: Ann Arbor, Michigan
- Contact:
Re: Memory leak with images?
Markusv wrote:on my webpage...
What's the URL of the webpage? If you give it to us, we can check out if it's a problem with Firefox or not.
- Dartman
- Moderator
- Posts: 11995
- Joined: February 9th, 2006, 9:43 pm
-
- Posts: 5
- Joined: March 7th, 2007, 1:18 am
-
- Posts: 3483
- Joined: November 4th, 2002, 10:47 pm
- Location: Ann Arbor, Michigan
- Contact:
- Dartman
- Moderator
- Posts: 11995
- Joined: February 9th, 2006, 9:43 pm
markusv wrote:hi
I have no registered with the user name markusv, when you transfer me can you give me a link to the new post?
Hi markusv,
There will be no new link, nor will you need to repost this question in the other forum. I will move this thread/topic over to the Web Development Forum for you.
Moving to Web Development.
Alcohol and Calculus don't mix. Never drink and derive.
-
- Posts: 3483
- Joined: November 4th, 2002, 10:47 pm
- Location: Ann Arbor, Michigan
- Contact:
The bug was reported over three years ago and has only two votes. It doesn't seem like users think it's a big deal, so I'm not surprised it hasn't been fixed. They're looking for someone to work on fixing it.
As for a workaround, I can't see that anyone has come up with one. Perhaps you could discuss it in the bug report.
As for a workaround, I can't see that anyone has come up with one. Perhaps you could discuss it in the bug report.
- jscher2000
- Posts: 11762
- Joined: December 19th, 2004, 12:26 am
- Location: Silicon Valley, CA USA
- Contact:
To avoid the problem of changing out the image before it has finished loading, use the image's onload event handler. Here's a simple example:
Note to anyone testing this: you need 18 or 19 images named starting with test0.jpg to avoid the script stopping.
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Image Intervals</title>
<script type="text/javascript">
function timerCallback() {
var NUM_OF_SLIDES = 18;
var randomnumber = Math.floor(Math.random()*NUM_OF_SLIDES)
var nuImgName = "test"+randomnumber+".jpg";
var slideImg = document.getElementById("slideImage");
slideImg.onload = timerDelay;
slideImg.src = nuImgName;
// For logging debug info only
var debug = document.getElementById("filenames");
debug.innerHTML += "<br>\n" + nuImgName;
}
function timerDelay() {
setTimeout("timerCallback()", 500);
}
window.onload = function() {
timerDelay();
};
</script>
</head>
<body>
<div id="container">
<img id="slideImage" src="">
<div>
<!-- for Logging debug info only -->
<p id="filenames">Debug Info:</p>
</body>
</html>
Note to anyone testing this: you need 18 or 19 images named starting with test0.jpg to avoid the script stopping.
- jscher2000
- Posts: 11762
- Joined: December 19th, 2004, 12:26 am
- Location: Silicon Valley, CA USA
- Contact:
-
- Posts: 2
- Joined: June 3rd, 2007, 10:19 pm
Hello,
this is exact the problem i am struggling with. The page runs some seconds and than the memory usage of firefox 2.0.0.4 explodes, goes up to 300MB and than my system crashes (I use always the same image url and read the image from a webcam, I reduced the delay to speed up the problem). Is there a solution for this problem?
Regards
Broesel
this is exact the problem i am struggling with. The page runs some seconds and than the memory usage of firefox 2.0.0.4 explodes, goes up to 300MB and than my system crashes (I use always the same image url and read the image from a webcam, I reduced the delay to speed up the problem). Is there a solution for this problem?
Regards
Broesel
-
- Posts: 6108
- Joined: November 18th, 2002, 11:07 am
-
- Posts: 3483
- Joined: November 4th, 2002, 10:47 pm
- Location: Ann Arbor, Michigan
- Contact:
Racer wrote:I'm surprised this has not been addressed yet. There are quite a few sites that do dynamic image loading using this method. Since the bug hasn't been looked at since 2005, I don't forsee any forthcoming fix unless alot of noise is made -- squeaky wheel & such.
If you can name some sites that cause Firefox to exhibit this memory problem, please do. That will help convince developers that the issue needs to be addressed.