Loading External Images Causes Memory Leak

I have been working on an Actionscript 2.0 project that basically loads external images.
Everytime i load and unload a new image, memory increases to 1 or 2 MBs
If all the images are in cache, then it increased to 4 or 8 KBs
In the unloading of images, I have removed loader and the container of the image.
Any thoughts why it is behaving like that?
Please find the sample code snippet below.
btn_load.onRelease = function()
loadImage();
btn_unLoad.onRelease = function()
unLoadImage();
var mcListener:Object = new Object();
var container1:MovieClip;
var mcLoader:MovieClipLoader;
var loader_reference = this;
var n=0;
function loadImage(){
var image_arr = ["http://xyz.com/image1.png","http://xyz.com/image2.png","http://xyz.com/image3.png","http:/ /xyz.com/image4.png","http://xyz.com/image5.png"];
var image_url = image_arr[n];
if(n==image_arr.length-1) {
  n=0;
}else{ 
  n++;
container1 = loader_reference.createEmptyMovieClip("container1", loader_reference.getNextHighestDepth());
mcLoader = new MovieClipLoader();
mcLoader.removeListener(mcListener);
mcLoader.addListener(mcListener);
mcListener.onLoadComplete = function(target_mc:MovieClip, httpStatus:Number):Void {
mcListener.onLoadInit = function(target_mc:MovieClip):Void {
  target_mc._x = 300;
  target_mc._y = 200;
  target_mc._width = 300;
  target_mc._height = 250;
mcLoader.loadClip(image_url, container1);
function unLoadImage(){
  mcLoader.unloadClip(container1);
  mcLoader = null;
  container1 = null;
  removeMovieClip(loader_reference.container1);
Thanks in advance.

that code should only execute once.  fix that.

Similar Messages

  • Calling SetLocalTime in C# causes Memory Leak (WEC7)

    Hello,
    I use SetLocalTime() in C#. Everything works well if I start explorer.exe and my application. But if I don't start explorer.exe at system start. SetLocalTime() causes memory leak in my application. I call the function frequently every hour.
    public static bool SetzeLokalZeit(SYSTEMDATETIME lpSystemTime)
    #if DEADLOCKDETECT
    using (DdMonitor.Lock(MyTimeLock, "MyTimeLock#1"))
    #else
    lock (MyTimeLock)
    #endif
    bool ret = false; // no Success
    try
    GLB.LogFile.MyWrite("SetLocalTime");
    SYSTEMDATETIME loc = new SYSTEMDATETIME();
    loc.wYear = lpSystemTime.wYear;
    loc.wMonth = lpSystemTime.wMonth;
    loc.wDayOfWeek = lpSystemTime.wDayOfWeek;
    loc.wDay = lpSystemTime.wDay;
    loc.wHour = lpSystemTime.wHour;
    loc.wMinute = lpSystemTime.wMinute;
    loc.wSecond = lpSystemTime.wSecond;
    loc.wMilliseconds = lpSystemTime.wMilliseconds;
    ret = SetLocalTime(ref loc);
    if (!ret) // no Success
    int err = Marshal.GetLastWin32Error();
    if (err > 0)
    GLB.LogFile.MyWrite("ERROR CODE:" + err.ToString());
    else ret = true;
    catch (Exception ex)
    GLB.LogFile.MyWrite("000023 Exception" + ex.Message);
    finally
    GLB.LogFile.MyWrite("SetLocalTime Ende");
    return ret;
    Has someone an idea what's the problem?
    Best regards,
    Andreas

    Hello,
    Here the answers to the questions:
    1. Does the SetLocalTime function succeed?
    Calling SetLocalTime doesn't cause an exception an the local time is set correctly.
    2. Do you still get the memory leak if you remove all other calls?
    Yes. I have removed any other code, but I also get the memory leak.
    3. Does the memory leak also occur when you do this from native code?
    I have not tried it yet. But I will still make it...
    [DllImport("coredll.dll")]
    private static extern void GetLocalTime(ref SYSTEMDATETIME lpSystemTime);
    [DllImport("coredll.dll", SetLastError = true)]
    private static extern bool SetLocalTime(ref SYSTEMDATETIME lpSystemTime);
    [StructLayout(LayoutKind.Sequential)]
    public struct SYSTEMDATETIME
    public ushort wYear;
    public ushort wMonth;
    public ushort wDayOfWeek;
    public ushort wDay;
    public ushort wHour;
    public ushort wMinute;
    public ushort wSecond;
    public ushort wMilliseconds;
    public static bool Pub_SetLocalTime(SYSTEMDATETIME lpSystemTime)
    lock (MyTimeLock)
    bool ret = false; // no Success
    try
    loc_set.wYear = lpSystemTime.wYear;
    loc_set.wMonth = lpSystemTime.wMonth;
    loc_set.wDayOfWeek = lpSystemTime.wDayOfWeek;
    loc_set.wDay = lpSystemTime.wDay;
    loc_set.wHour = lpSystemTime.wHour;
    loc_set.wMinute = lpSystemTime.wMinute;
    loc_set.wSecond = lpSystemTime.wSecond;
    loc_set.wMilliseconds = lpSystemTime.wMilliseconds;
    ret = SetLocalTime(ref loc_set);
    if (!ret) // no Success
    int err = Marshal.GetLastWin32Error();
    if (err > 0)
    MessageBox.Show("Win32 Error:", err.ToString());
    else ret = true;
    catch (Exception ex)
    MessageBox.Show("SetLocalTime,Exception:", ex.ToString());
    finally
    return ret;
    Best regards,
    Andreas

  • JSF: partial page rendering is causing memory leak leading to outofmemory

    JDeveloper 10.1.3.2.0
    JDK: 1.6.0_06
    Operating System: Windows XP.
    I test my application for memory leaks. For that purpose, I use jconsole to monitor java heap space. I have an edit page that has two dependent list components. One displays all countries and the other displays cities of the selected country.
    I noticed java heap space keeps growing as I change country from country list.
    I run garbage collection and memory usage does not go down. If I keep changing the province for 5 minutes, then I hit a java heap space outofmemory exception.
    To narrow down the problem, I removed the second city component and the problem still exists.
    To narrow it down further, I removed autosubmit attribute from the country component and then memory usage stopped increasing as I change country.
    country/city partial page rendering is just an example. I am able to reproduce the same problem on every page where i use partial page rendering. My conclusion is PPR is causing memory leak or at least the autosubmit attribute.
    This is really bad. Anyone out there experienced same issue. Any help/advice is highly appreciated !!
    Thanks
    <af:panelLabelAndMessage
    inlineStyle="font-weight:bold;"
    label="Country:"
    tip=" "
    showRequired="true"
    for="CountryId">
    <af:selectOneChoice id="CountryId"
                   valuePassThru="true"
                   value="#{bindings.CountryId.inputValue}"
                   autoSubmit="true"
                   inlineStyle="width:221px"
                   simple="true">
         <af:forEach var="item"
              items="#{bindings.CountriesListIterator.allRowsInRange}">
         <af:selectItem value="#{item.countryId}"
                   label="#{item.countryName}"/>
         </af:forEach>
    </af:selectOneChoice>
    </af:panelLabelAndMessage>
    <af:panelLabelAndMessage
    inlineStyle="font-weight:bold;"
    label="City:"
    tip=" "
    showRequired="true"
    for="CityId">
    <af:selectOneChoice id="CityId"
                   valuePassThru="true"
                   value="#{bindings.CityId.inputValue}"
                   partialTriggers="CountryId"
                   autoSubmit="true"
                   inlineStyle="width:221px"
                   unselectedLabel="--Select City--"
                   simple="true">
         <f:selectItems value="#{backing_CountryCityBean.citiesSelectItems}"/>
    </af:selectOneChoice>
    </af:panelLabelAndMessage>

    Samsam,
    I haven't seen this problem myself, no.
    To clarify - are you seeing this behaviour when running your app in JDeveloper, or when running in an application server? If in JDeveloper, a copuple of suggestions:
    * (may not matter, but...) It's not supported to run JDev 10g with JDK 6
    * have you tried the [url http://www.oracle.com/technology/pub/articles/masterj2ee/j2ee_wk11.html]memory profiler
    Best,
    John

  • Load external images

    Im wanting to make a photo gallery that I can update easy, I
    thought if I could have a movieclip load external images for my
    thumbnails it would be nice but Im not sure how to set it up. I
    would make a file for my images and then another for my thumbnails,
    then if or when I want to switch out pictures I'd just have to drop
    new images into my folders and not even touch the FLA. Could anyone
    point me in the right direction with the right action script to use
    or a tutorial that explains how this is done..
    And when I say load external I want it so I dont have to
    click on the image for it to load, I want it to just load
    automatically , I would put an invisible button or something to
    that efect over the images for a animated effect.
    Thanks for your help.

    I don't know if you are super enthusiastic about building it,
    or if you just want the utility. If the later is the case, I just
    purchased (cheap) a really great product that does all of what you
    want, fairly automatically, including scaling large pictures down
    to smaller size so that they load quickly.
    I am not sure of the policy of recommending third-party
    applicatons here. So, if you are interested, send an email (private
    message) to me and I will show you the simple site I put together
    using it and where to get it.

  • Load external images and video in edge

    Hi.
    I am looking into edge instead of flash.
    My question is how do you load external images and videos from an external server?
    To clarify, I need to insert a link from where the images can load into the stage, so they don´t take up any of the final weight.
    Thanks in advance.
    Best,
    Stig.

    The above solution I provided works if you already have the images in your composition and than if you want form load images from another server rather than the relative location to your html file.
    Now if you want to load images dynamically into a rectagle containter you will have to code it.
    below is a sample for that
    Create a 'rectangle' with name 'Rectagle'.
    Add the snippet in the compositon ready or on other user actiosn based on your requirement
    var myImagetag = '<img src="http://wwwimages.adobe.com/include/style/default/SiteHeader/logo-2x.png">'
    sym.$("Rectangle").append(myImagetag);

  • Can Java program cause memory leak?

    Can Java program cause memory leak or memory crash? I don't mean any memory overflow related exceptions. I mean something like core dump in UNIX or error reports in Windows XP.
    If it can really happen, in what circumstances? I raise such a question because our J2EE based system had really caused memory leak in Windows XP systems, but so far we still fail to troubleshoot the problem.

    Your code may leak memory. There are many, many, many reasons this could be. All of them represent bugs in your code.
    You should get a profiler to identify the problem spots of your code.
    You spoke of a memory crash as well. The VM may crash with some bug in the VM, or a bug in native code but that is not relevent to your problem. A memory leak is a problem in your code.

  • Best Practice - load external image including rollovers

    I am attempting to use the loader component to load an
    external jpg, but experience issues having my flash app
    successfully load a roll-over image from an external source when
    the user rolls over the intital jpg. I am not a flash developer
    (actually a .net developer trying to help a graphics guy out).
    I started with the loader component, converted it to a movie
    clip and then utilized the on(rollover) and on(rollout) events to
    change the loader component's contentPath property at runtime via
    ActionScript. I am not getting consistent results with this
    strategy - what is the best way to accomplish this? Also note I
    tried converted to a button, which seemed more logical, but the
    loader component doesn't seem to like being converted to a button.
    Regards,
    Daflookie

    Daflookie,
    > I started with the loader component, converted it to a
    movie
    > clip and then utilized the on(rollover) and on(rollout)
    events
    > to change the loader component's contentPath property at
    > runtime via ActionScript. I am not getting consistent
    results
    Check out the Loader class in the Components Language
    Reference. Loader
    extends MovieClip, so there's no need to convert to a movie
    clip symbol. In
    addition, I recommend scrapping on() in favor of MovieClip
    events, which
    will probably be closer to your .NET point of view that the
    older
    on/onClipEvent approach to event handling (those are Flash
    5-era).
    Honestly, though, if you simply want to load images, I would
    forego the
    Loader component (no need for all that overhead) and use
    MovieClipLoader to
    load your images into the user's Internet cache. You'll see a
    good handful
    of events under that class listing as well (see the
    ActionScript 2.0
    Language Reference).
    David Stiller
    Adobe Community Expert
    Dev blog,
    http://www.quip.net/blog/
    "Luck is the residue of good design."

  • Making a loaded external image into a button in Actionscript

    My name is Steve Oatman I am a student at
    AIO for a Web Design Diploma
    class: Interactive Telecommunications IMD412 XA
    Professors to bussy!
    I have a flash web site that I am putting together. I am using AS to load some images from an external source. These images are being loaded into a movieclip. These images need to become buttons once they are loaded. The images will link to the particular menu category pages beef, chicken, etc.
    The images are loading fine they just are not responding like a button or link.
    I am getting two error referencing the buttonMode and usehandCursor. Below is just one image that I am working on till I get it to work.
    I am getting these two Compiler error code:
    1119: Access of possibly undefined property buttonMode through a reference with static type flash.display:Loader.
    1119: Access of possibly undefined property useHandCursor through a reference with static type flash.display:Loader.
    This is what I have.
    var myLoader01:Loader = new Loader();
    myLoader01.load(new URLRequest("entrees_images/beef/beef01.gif"));
    addChild(myLoader01);
    myLoader01.x = -269;
    myLoader01.y = -164;
    myLoader01.buttonMode = true;
    myLoader01.useHandCursor = true;
    myLoader01.addEventListener(MouseEvent.CLICK, beefClick);
    function beefClick(event:MouseEvent):void{
    gotoAndStop("beef");
    From me searching online I thought the
    name.buttonMode = true;
    turned the element into a button!
    I have included the fla file. This is in the menuItems_mc which is located in the pageContent_mc frame 40 layer page Image or of course the library.
    I know this is a little in depth sorry and any help would be greatly appreciated.
    Steve
    713/742-3325

    Try something along the following lines:
    var myLoader01:Loader = new Loader();
    function addIt(evt:Event):void{
       var aBtn:MovieClip = new MovieClip();
       aBtn.x = -269;
       aBtn.y = -164;
       aBtn.buttonMode = true;
       addChild(aBtn);
       aBtn.addChild(myLoader01);
       aBtn.addEventListener(MouseEvent.CLICK, beefClick);
    myLoader01.contentLoaderInfo.addEventListener(Event.COMPLETE, addIt);
    myLoader01.load(new URLRequest("entrees_images/beef/beef01.gif"));
    function beefClick(event:MouseEvent):void{
       gotoAndStop("beef");

  • AS3 Load external image and add multiple instances to mcs

    Hi,
    Is there any way to load an external image and add it to more than one movie clip?
    Thanks,
    Chris McLaughlin

    Hi kglad,
    I was loading a larger jpeg to which I was applying 20 different masks so using the bitmapdata class to create duplicates was the best solution.
    It took me some time to wrap my head around it, but all is well.
    Thanks for pointing me in the right direction.
    Best regards,
    Chris

  • Loading external Images in MovieClips

    Dear All,
    I am trying to load the external images in Dynamically
    created Movie Clips.
    Can you please help me out from this.
    I am trying something like this:
    Container_mc.image_mc ( I want to load the Images inside the
    imag_mc clip)
    Regards,
    Sridhar B
    Container_mc.image_mc
    imag_mc

    Hi,
    Following is my problem:
    I am trying to trace the "idValue" property on runtime but it
    is showing error. Can you please tellme how add Images and
    properties runtime.
    var loader:Loader = new Loader()
    addChild(loader)
    loader.load(new URLRequest("images/01.png"))
    // Assigning a value to idValue property
    mc_mainSWF.idValue = 40
    mc_mainSWF.addChild(loader)
    mc_mainSWF.addEventListener(MouseEvent.CLICK, checkID)
    function checkID(event:MouseEvent)
    // And i am geeting error here
    trace(event.target.idValue)
    Regards,
    Sridhar B

  • Loading External Images

    Hey, I've been having a niggly problem for a while now. I'm
    using MovieClipLoader and a Listener to load in external images.
    All the images load in fine, but often (not always) the onLoadInit
    and onLoadComplete events don't seem to work on the last image I
    load, so if I've got a dynamic text box that I want to disappear
    when loading is complete, it doesn't, only on the last image of a
    group, even tho the image itself loads correctly.
    Anyone come across this before? You can see an example on the
    index page of
    this site.

    nice site, good job :) I would guess that if you are using
    both events on the same call, one is getting triggered before the
    other, since they both operate at a similar time. similar but not
    the same, onLoadComplete happens when the load is complete,
    onLoadInit happens when the first frame of the loaded timeline
    plays. Therefore if your listening for both on the same load call,
    one may happen before the other, and may override or change the
    event sequence, occationally.
    Just a guess though, I think you should consider using one or
    the other, and firing all other functions from there.

  • Load external image and animate?

    This may be a naive question, but -
    What is the best method to draw external content (an image
    file) into a Flash movie, AND then ANIMATE that content?
    I assumed I would need to use the LOADER COMPONENT to draw an
    image file from an external URL, but is there a way to then perform
    a simple animation (e.g., slide the image across the stage) with
    the loaded image? I cannot seem to figure out how to manipulate an
    image once loaded (using the LOADER COMPONENT).
    Yes, I am new to Flash, so there may be six other ways to do
    this of which I am not aware.
    Suggestions/solutions?

    use the MovieClipLoader class to load the image into a holder
    movie clip, then use the onLoadInit function to animate the holder
    clip.

  • The Security ID is not valid causes memory leak in Ldap

    Hi, all:
    We are using the Novell LDAP Provider to allow our server application
    be configured in LDAP mode. One of our clients is experiencing a memory
    leak and we believe that the problem could be related to a "The Security
    ID is not valid" error. When he changes to native Active Directory mode
    the memory leak dissapears (he still gets the "Security ID" error, but
    all works fine). So, we think that the problem caused by the "Security
    ID" error is affecting the Novell Ldap Provider library. He is using a
    Windows 2008 R2 platform.
    My question is: Do you know if these kind of errors are properly
    handled so that resources are released?
    We are using the 2.1.10.1 version of the library.
    Many thanks for you help,
    Luis
    luixrodix
    luixrodix's Profile: http://forums.novell.com/member.php?userid=107647
    View this thread: http://forums.novell.com/showthread.php?t=435894

    ab;2091346 Wrote:
    > -----BEGIN PGP SIGNED MESSAGE-----
    > Hash: SHA1
    >
    > Have the exact error message? Is it safe to assume you are querying
    > MAD
    > and not eDirectory? I make that assumption because you mentioned
    > SIDs.
    >
    > Good luck.
    >
    > Yes the message is: "The Security ID structure is invalid". It is the
    > error 1337 of Windows and cannot be fixed manually since SIDs cannot be
    > modified manually.
    >
    >
    > When the client has configured our tool as Active Directory via LDAP
    > (using the Novell Ldap library) the error is not logged anywhere (that's
    > another reason for thinking that the library is not handling the error
    > correctly) and the application has memory leaks everytime the AD server
    > is queried, but when they use the same Active Directory but in a pure AD
    > configuration (using System.DirectoryServices and Windows API directly)
    > the error is logged and the memory of the application remains stable.
    >
    > I asked the client to fix the Security ID problem, trying to find the
    > user(s) whose SID are wrong and re-creating them, but if the Novell.Ldap
    > library is not handling this error correctly the potential problem is
    > still there.
    >
    >
    >
    >
    >
    > On 03/30/2011 08:36 AM, luixrodix wrote:
    > >
    > > I mean, everytime a query is sent to the LDAP server an Invalid SID
    > is
    > > reported, and some resources are not released. We think that the
    > problem
    > > could be in the LDAP Novell library.
    > >
    > >
    > -----BEGIN PGP SIGNATURE-----
    > Version: GnuPG v2.0.15 (GNU/Linux)
    > Comment: Using GnuPG with Mozilla - 'Enigmail: A simple interface for
    > OpenPGP email security' (http://enigmail.mozdev.org/)
    >
    > iQIcBAEBAgAGBQJNk2bcAAoJEF+XTK08PnB5K1oP/RB5AUOUtXi13jS/3bSG0wVC
    > uErEfdqBj6R7yliZ8oqkLApQXzEomMwmSRwa4K6v+Rj1MDFBW+ nBFTOv4aHVgq53
    > ANslfM0inboZIxuQxBEhB/5HD062s4yGHTgL81LgeKdYyZvx0np6zmgDOVA/Ogx5
    > GS0nQfAhUZ+tAlgrhzRj3FB9WaamSQsdmEbXCTLjIrhy2FjH14 RidAmY0civvAsw
    > 5EoAlPe56JzQWhdzyIMhodVB2lIa2b+ttoKY7+Q35PsW2KJ3zl +O2MgHBdBtGUOQ
    > DekIR3h5kOjsRGAia8Td1eqSjziNB04fBcjR++B1vLuzE7YSGR mfRVAofOdjtlsR
    > lQ7sRX5Wg9cKN0KniMmvgrKaMqYcnl3wGgvhbVDA+vgriOxnRt PRssrTckrRaOcU
    > KvE3efwvgbdWeRNdfVAwU2qMPrsEA051XBtRKCclv5Ebi6AgwZ uuT3rYRm2Ycusy
    > TebrcX+YkiCZE+GYfULzN2KDUoxCbB85xBGwsg9Iz2/nTt6mkHT0+KqNM713uNJX
    > OqtJJP1fvfw6JMeQW5rS0VrTl2yGncJHf+cvrp0cXx8l+CJkB3 X7phZ5N0c1ttTc
    > 9cPCT+WuC7lCn4QviC8QlmZUYfbGDZmYbxm4ewUalB4J6uoBgy HPSbDITHXIeTz9
    > ISovMI9iFXzrS+Cjd7dk
    > =HEVD
    > -----END PGP SIGNATURE-----
    luixrodix
    luixrodix's Profile: http://forums.novell.com/member.php?userid=107647
    View this thread: http://forums.novell.com/showthread.php?t=435894

  • Load external image & text into SWF

    Can someone point me to a tutorial on how to create a
    template that will load an external image file,.css styled text
    & a .css style sheet into a .swf by using .xml?
    Thank you for your time.
    CK

    You can use the MovieClipLoader class to load multiple images sequentially (one at a time), but you wouldn't use a 'for' type of loop...instead you would use a recursive loop, where a loading function is called after each load completion until all loading in done.  This is done by utilizing a load-complete listener to trigger loading of the next image.  So you start the loading process by loading one file, when that file is determined to be loaded, the listener proceses that file in whatever way you need to prepared (resizing, etc) and triggers the loading of the next file.
    If you look up the MovieClipLoader.addListener method in the Flash help documents there is an example there that uses the onLoadInit event.  You would be wanting to use the onLoadComplete event.

  • Unable to load external image into iOS app with AS3

    Just trying out Flash Builder for iOS app development and have run into a problem right off the bat with loading an external image into an iOS app.  The actionscript is very simple (this was basically my Hello World attempt), and I'm hoping someone here can explain where I'm going wrong.  This code works in Flash Pro, and works when launched on the desktop from Flash Builder, but doesn't work on my iOS devices.
    Here's the code:
                                  var container:MovieClip = new MovieClip();
                                  addChild(container);
                                  var imageLoader:Loader = new Loader();
           imageLoader.load(new URLRequest("http://www.google.ca/intl/en_ALL/images/logos/images_logo_lg.gif"));
                                  imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, startListener);
      function startListener (e:Event):void{
                                                 container.addChild(imageLoader);
    Any thoughts on why this won't work would be greatly appreciated!

    I had the same issue, and modified my domain policy file as specified  in http://www.adobe.com/devnet/flashplayer/articles/fplayer9_security.html#_Configuring_URL_M eta-Policies but the loader is not loading the file. Any ideas on how to fix this issue?

Maybe you are looking for

  • Exception in thread "JMF thread???

    I try to write a very simple project which just play a local media in an Applet, although this example can be found in a lot of places, I met an Exception which kind of strange, Can anyone met this before? My Code is very simple. import java.applet.A

  • How is BADI  linked to a transaction.

    Hi All,            I want to know how a BADI is linked to the transaction. I found a BADI WF_BWP_SELECT_FILTER is linked to the transaction SBWP. The BADI is returing a parameter to the transaction. My doubt is now i creating a report program .Is it

  • Can I store old TV shows on another disk drive to save space?

    My itunes is eating up available disk space, and there are some TV shows I seldom watch.  Can I store them on an auxiliary drive?  Can I delete them on my MacBook and get them back from the cloud?

  • Server Behaviors Panel and Menu Dropdown Missing

    Is there an easy way to re-install or activate the Server Behaviors Panel and Functions in Dreamweaver CC, where it appears to have been de-emphsized?

  • Error: Failed to open Address Book database

    Help!  I keep getting this error message.  Other posts said to sync with address book defaulting to handheld but the desktop software won't even open so I can't sync.  Any suggestions??  I haven't synced for a very long time! Post relates to: Tungste