• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Memory leak w/ large movieclip

Contributor ,
May 26, 2011 May 26, 2011

Copy link to clipboard

Copied

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.

TOPICS
ActionScript

Views

651

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 27, 2011 May 27, 2011

Copy link to clipboard

Copied

Hello,

#1

if there is BitmapData instance somewhere call dispose() on it and then nullify:

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/BitmapData.html#dispose()

#2

if there is XML data involved you could use flash.system.System.disposeXML():

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/System.html#disposeXML()

In both there is not enough to nullify them for immediate gc I think.

regards,

Peter

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 30, 2011 May 30, 2011

Copy link to clipboard

Copied

LATEST

Thanks, but I don't have either of those things in the project.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines