dashboard/javascript/noob question

Discussion in 'Mac Programming' started by yod9999, Feb 10, 2007.

  1. yod9999 macrumors newbie

    Jan 6, 2007

    sorry if this is a fairly stupid question, but i've never really done any web programming before.

    i've created a really simple widget do display a picture from a webcam on the dashboard, it uses javascript to refresh the image once a second.

    <script type="text/javascript">
    function fetchImage()
    	var now = new Date();
    	var zm_image = new Image();
    	zm_image.src = ''+'&'+now.getTime();
    	document['zmImage'].src = zm_image.src;
    	delete zm_image;
    window.setInterval( "fetchImage()", 1000 );
    <img name="zmImage" src="" alt="BackGarden" border="0" width="320" height="240">	
    i told you it was simple :) (the url is just a random one i picked off the net)

    the problem is that the widget process seems to use a huge amount of memory. each image is about 16kb, but 5 minutes after launching the widget in activity monitor the dashboard client process shows as using 107MB of real memory and 450MB of virtual memory. the figures are fairly stable once they reach these levels so it's not like there's a proper memory leak, but it does seem like an excessive amount of memory. is this normal/a problem? is there anything i can do to reduce the amount of memory used?



Share This Page