Valty
asked on
JavaScript problem to reload images
Hello,
I have made a code who reload an image in an infinite loop.
But the problem is that the numbers of elements just growing up with the time, and on my iPhone with Mobile Safari, after a moment, the reloads just stop.
I think it's because of a memory saturation.
How can I do to "free" olds images ?
Sorry for my ugly english, and thanks in advance !
I have made a code who reload an image in an infinite loop.
But the problem is that the numbers of elements just growing up with the time, and on my iPhone with Mobile Safari, after a moment, the reloads just stop.
I think it's because of a memory saturation.
How can I do to "free" olds images ?
Sorry for my ugly english, and thanks in advance !
<html>
<script type="text/javascript" language="JavaScript">
image1 = new Image();
image2 = new Image();
function reloadImage() {
date = new Date();
document.getElementById("texte").innerHTML = date.getTime();
image1.src = 'image.php?time=' + date.getTime();
image2 = image1;
document.getElementById("webcam").src = image2.src;
}
function reloadTimer() {
setTimeout("reloadImage()", 500);
}
</script>
<div id="texte" >XXXX</div>
<img id="webcam" onLoad="reloadTimer()" src="image.php">
</html>
ASKER
Hello jazzllllove, thanks you for your fast answer
My code can download a picture of my webcam updated regularly. A sort of streaming, but with a single image.
I do JavaScript for a short time, I wanted to know if it was necessary to "liberate" the memory of the old images, or if my problem is not here.
Regards,
My code can download a picture of my webcam updated regularly. A sort of streaming, but with a single image.
I do JavaScript for a short time, I wanted to know if it was necessary to "liberate" the memory of the old images, or if my problem is not here.
Regards,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have read the link, but I'm not really familiar with this.
Are you sure the problem I have is in relation with memory leaks ?
I would be very grateful if you could give me a sample code
Are you sure the problem I have is in relation with memory leaks ?
I would be very grateful if you could give me a sample code
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hello wilq32, thanks you for your answer
I have already tested with delete, but according to this post, my problem seems to be a specific mobile safari problem, because I have not this problem with other browsers :
http://groups.google.com/group/iphonewebdev/browse_thread/thread/78eeb249726f27f6?hl=en
I have already tested with delete, but according to this post, my problem seems to be a specific mobile safari problem, because I have not this problem with other browsers :
http://groups.google.com/group/iphonewebdev/browse_thread/thread/78eeb249726f27f6?hl=en
nothing more to add :( just wait for new version of mobile browser..
ASKER
Yes, I think this is the best I can do for the moment, I assign the points !
ASKER
Thanks !
<<I have made a code who reload an image in an infinite loop.
Why is that? Purpose?
<<How can I do to "free" olds images ?
What's that?
Best regards...