Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Dashboard bug or mine?! Memory Leak reloading new images...



Hi,

I am really looking for help on that point.

If you write a simple code loading a new image from the internet every minutes and launch a top you will be surprised.
I checked different code from the internet and I found the same issue (very few KB of memory leak on each refresh).

In my case I refresh an animated gif, I do not know why but the code is easy as the following, but I get 2MB of leak every images!
It looks like memory regions are growing indefinitely like I had to release something! Am I doing something wrong? What about dashboard cache?

Can someone help me?

Cheers,
Eric.


function refresh(url)
{
    document.getElementById("loading").src = ""> '?' + Math.floor(Math.random() * 1000);
}


Date: Mon, 9 May 2005 19:41:35 +0200
From: Eric CIRCLAEYS <email@hidden>
Subject: My First Widget! Memory Leak reloading images...
Message-ID: <email@hidden">email@hidden>
Content-Type: text/plain; charset="us-ascii"

Hi Everyone,

I am developing my first widget that displays a basic image from the
internet that is refreshed every minutes.
I implemented the onshow and onhide to avoid refreshing the image
permanently.

All look to be working very well.

The big problem is that each time the image is re-loaded from the
Internet I gain an additional 2MB in my widget process memory!
So I got a memory link! How can I release my old image? Thought it
was automatic? Do not really understand what is happening.

I am refreshing the image with a timer that uses a new _javascript_
image object and that calls the onload callback and then reloads the
picture doing a new <img> tag in a <div> space (as you can see in the
attached code).

Can you help me?

Thank you very much in advance for your help!
All the best,
Eric.


Sorry if this looks like hell, this is my first web/_javascript_ code :)


function refresh(url)
{
     loadImage(url + '?' + Math.floor(Math.random() * 1000), gWidth,
gHeight);
}

function loadImage(url, width, height)
{
     var tmpimage = new Image();

     tmpimage.>
     tmpimage.>
     tmpimage. width, height);

     tmpimage.src = "">
}

function imageLoaded(url, width, height)
{
     var results = document.getElementById("results");
     var    tmpresults = "";

     tmpresults = '<img STYLE="position:absolute; LEFT: 6px; TOP:
6px; WIDTH: ' + width*gRatio + 'px; HEIGHT: ' + height*gRatio + 'px;"
id="image" src=""></img>';

     results.innerHTML = tmpresults;

     window.resizeTo(width*gRatio+18, height*gRatio+18);
     backimage.width = width*gRatio+18;
     backimage.height = height*gRatio+18;
}

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Dashboard-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/dashboard-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.