can I clear my cache?

January 7th, 2009
  • can I clear my cache?
    any good tutorials on caching, I've seen the examples. seems like everyone wants to know?


  • well we need more info to be able to help you out. You're just saying that your application crashes after 7 hours... do you have something that stores itself in the memory and slowly fills it up?


  • I don't really understand. I'm attempting to use cacheAsBitmap but the player or exe file always crashes after about 7 hours of run time because the computer is out of memory. I thought it might have something to do with the cache and was wondering if I could clear/empty it.


  • ok, great link. I posted it for some others too. however I'm having trouble figuring out have to couple the below code with what I posted above to take out the memory leak. Do you or anyone else have any clues.
    many thanks for any advice.

    foo = new flash.display.BitmapData(500,500);
    function onEnterFrame() {
    // reuse foo:
    foo.noise(1);
    mc.attachBitmap(foo,1);
    }


  • it's in a gallery.
    so I guess the cache'ing isn't the problem, I can't imagine what it is. Any help would be soooo appreciated.
    It should be running all day.


  • well, I'm still hung up, so if anyone wants to help I would greatly appreciate it. I don't think it's all that difficult, I'm just missing something. I don't think I quite understand how to get rid of the memory leak properly and the code that kritikal offered is close but the map1 must remain a variable so that it can be called later again. I don't know anymore, brain sore, anyone? I can explain more if necessary.


  • No I don't think so. Not from Flash anyway. But you can take steps to aviod loading from cache. This is the simple task of adding a querystring at the end of the url with a unique string. Usually I use the Date-objects getTime() method.

    Here's a simple example using LoadVars:

    var myLV = new LoadVars()
    myLV.load("file.txt?anticache=" + (new Date()).getTime());


    /Mirandir


  • whatever would be helpful, I'm not that versed either. It's more about the bug that needs to be fixed and the use of the dispose function then the actual BitmapData info. I just can't get my file to work with the options offered by skinner nor am I sure it is clearing the cache correctly because when I work around it, my memory usage still seems to expand causeing a fatal error. Bore. Sorry to be such a bug myself, but it's turned into one of those need to resolve as soon as possible issues for me and I don't know where to turn cause I don't know anyone else, other than this great big loving community of flashers.


  • thanks. never even heard of dispose. I've attempted to add the dispose script but it doesn't seem to work for me the way I would like it. Are you real farmiliar with it? I can get it to dispose of the bitmapdata, but I need it again later along the timeline, but I think it gets set to width -1 and height -1. Not sure how to call it back. man this is paining me.


  • I'd say the onEnterFrame is causing your player to crash.

    by doing map1.draw(cont1); the variable map1 isn't being disposed when the function finishes executing and seeing that the bitmap you're creating is pretty large you're filling up your virtual memory pretty fast.

    Usually function variables only exist during the execution of the function so in another words function variables are marked for deletion as soon as the function finishes executing but it doesn't seem to work well with the BitmapData objects.

    here take a look at the dispoe method maybe that can help you out
    http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001949.html

    *edit*
    to answer your question yes you can clear your "cache" by doing map1.dispose


  • not that I know of, but that was my first inclination and since I wasn't sure how the cacheasbitmap worked I jumped to that conclusion.
    here is the code I am executing if it helps.

    import flash.display.BitmapData;

    // the displacement maps
    var map1:BitmapData = new BitmapData(1080, 790, true, 0xFF000000);

    //bmps hold the displacement maps bitmap
    this.createEmptyMovieClip("bmp1", 10);
    bmp1.attachBitmap(map1, 0, "auto", true );

    // blur filter
    var blur = new flash.filters.BlurFilter(6,6,3);

    // displacementMapFilters
    var mapPoint = new flash.geom.Point(0,0);
    var dmfr = new flash.filters.DisplacementMapFilter(map1,mapPoint, 1,1,-30,-30,"clamp",0,0);

    // these contain the animated vector graphic which will be drawn to the displacement map
    this.createEmptyMovieClip("cont1", 100);
    cont1._visible = false;

    // Apply blur filter to bmps which is used to fade out the displacement map
    bmp1.filters = [blur];

    bmp1._visible = false;

    onMouseMove = function()
    {
    var d = cont1.getNextHighestDepth();
    var mc1 = cont1.attachMovie("circle", "c"+d, d);
    mc1._x = this._xmouse;
    mc1._y = this._ymouse;
    mc1.cacheAsBitmap = true;
    };

    jss.onEnterFrame = function()
    {
    map1.draw(cont1);
    map1.draw(bmp1);
    this.filters = [dmfr];
    };


  • not all that much familiar since I didn't get a chance to play with BitmapData yet but here's an example of how you can keep a reference to the bitmap and dispose of it later

    map1 = null;
    function onEnterFrame() {
    map1.dispose();
    map1 = new flash.display.BitmapData(1080, 790, true, 0xFF000000);
    bmp1.attachBitmap(map1, 0, "auto", true);
    }


    *edit*
    btw I just remembered where I read all that info.
    http://www.gskinner.com/blog/archives/2005/10/major_flash_pla.html


  • Bitmap Caching tells the player to convert the contents of the target movie clip into a bitmap which it generates and stores in memory alongside the orginal vector equivalent. So depending on the way you're using cacheAsBitmap it may or may not affect your memory all that much.

    You shouldn't use it on a movie clip that's constantly being updated ie changing the alpha _xscale _yscale etc values. But even if in your case it's constantly being updated, it's not supposed to be stacked in your memory, all the rendere does is clear what was generated and regenerate a new bitmap. So it really depends on a lot of factors.

    By the way, why is it running for 7 straight hours if you don't mind me asking?


  • wow, ok I gotta go through this
    thanks a bunch


  • thanks. I'll try this and something I came up with, but since I don't know for the next 7 or 8 hours if it will work without crashing I will have to return to this thread a little later.


  • like I said before I don't have much experience with BitmapData but I'll give it a try later tonight







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about can I clear my cache? , Please add it free.