2 Replies Latest reply: May 30, 2011 7:08 PM by xTLS RSS

    Memory leak w/ large movieclip

    xTLS Community Member

      I'm having what strikes me as a stupid problem, but I can't figure it out myself... it could be a subtle nuance of Flash or just some knowledge I don't have, anyway... I'm making a Flash game with a main menu and multiple levels. We didn't organize our project right (just self-taught college students doing it in our free time) so we made a level before the main menu. I ended up putting the entire level, code and all, into a MovieClip. It creates an instance of that MC when you start a level (I'm sure this was a terrible idea).

       

      But it leaks when I delete the MovieClip and create a new one (i.e. quit the level to the main menu and then start it again). It originally leaked ~6MB each time you quit and started it again, but I've tightened it up to ~1MB, but I'd still like to fix that.

       

      I know to Garbage Collect something you have to remove references, so I've

      1. Blanked all arrays
      2. Nulled all references
      3. Remove all MCs dynamically added to the stage and any associated events
      4. Removed every single MovieClip from the entire stage, including ones that weren't added dynamically
      5. Nulled practically every object and variable

       

      I've only used weak-referenced events, and I've removed all of them anyway, but it's still leaking. There's way too much code for me to post all of it, so I guess I'm just wondering if anyone has any general ideas I haven't thought of.