A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: destroying arrays

  1. #1
    Senior Member
    Join Date
    Jul 2000
    Posts
    336
    Is there any way to destroy an array and free up the memory it was using while an swf file is still loaded?

    I have a module that is using data from Access to fill up its content. I am loading the data into flash pipe-delimited then splitting those values into seperate arrays. Depending on which button the user presses, depends on which data is queried for and loaded.

    Problem is, I was only using one set of arrays to store the data in. After loading a different set of data, I was re-instantiating the arrays, figuring this would clear them out and allow me to re-use them. But I now believe it may be creating the same array name in different memory areas...???

    Is there any way to clear to arrays before lading new data to them? Or should I scrap this entire process and preload all the data into their own arrays beforehand?

    Also, generally, how much data is too much to be loading at one time? Would a few tables with a hundred or two rows each be too much?

    Thanks for any and all responses.

  2. #2
    Arckid - Curving the Web
    Join Date
    Dec 2000
    Location
    India
    Posts
    1,412
    have you tried this ?

    delete MyArray;

    ?? check this ...

    or ... myArray = undefined;

  3. #3
    Senior Member
    Join Date
    Jul 2000
    Posts
    336
    as far as I know, there is no way to do something like

    delete myArray();

    or soemthing like that.

    Maybe I can use something like

    myArray.slice(0);

    to slice all entries from 0 to the end..??


  4. #4
    Arckid - Curving the Web
    Join Date
    Dec 2000
    Location
    India
    Posts
    1,412
    see this ...

    aashu = new Array("a","b","c");
    trace("before deleting :" + aashu[1]);
    delete aashu;
    trace("after deleting :" + aashu[1]);

    your solution is this ...

  5. #5
    Senior Member
    Join Date
    Jul 2000
    Posts
    336
    Thanks man, it helped out.

    I had to seriously debug some code, but everything seems to be working fine now.

    I swear I looked all over the docs for something like array.clear() or something, can couldnt find it.

    Learn something new everyday.

  6. #6
    Arckid - Curving the Web
    Join Date
    Dec 2000
    Location
    India
    Posts
    1,412
    one thing i found intersting ...

    when i am seeing the posts of yours and me ... is 107 and 1071 ... only 1 more ... lol

  7. #7
    Senior Member
    Join Date
    Jul 2000
    Posts
    336
    pretty funny.. I visit here quite often, and I only have 107 posts. It's like you've been here for like 10 years.. j/k


  8. #8
    Arckid - Curving the Web
    Join Date
    Dec 2000
    Location
    India
    Posts
    1,412

  9. #9
    Maya * ActionScript Addict DangerAhead's Avatar
    Join Date
    Jun 2000
    Location
    San Francisco
    Posts
    299

    very easy

    EASY!
    Code:
    // just set the length to zero
    // the length property is read and write
    
    nameOfYourArray.length = 0;

  10. #10
    Arckid - Curving the Web
    Join Date
    Dec 2000
    Location
    India
    Posts
    1,412
    never thought about this way!

    thanks for your suggestion ... i thought it was readonly property.

  11. #11
    [Devil in DarkGreen]

    Join Date
    Aug 2000
    Posts
    523
    nameOfYourArray.length = 0;

    a good tip,but it's still in memery,so nameOfYourArray=null;/nameOfYourArray=undefined;/delete nameOfYourArray;


    ...
    Code:
    while (yourarray.length) yourarray.pop();

    DS

  12. #12
    Arckid - Curving the Web
    Join Date
    Dec 2000
    Location
    India
    Posts
    1,412
    i think then the delete will be the best.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center