开发者

AS3: Too Large to Garbage Collect?

开发者 https://www.devze.com 2023-04-05 20:24 出处:网络
I\'m working on a flash game that has developed an obvious memory leak. I do what I\'m supposed to do with GC; remove all references to the object, nullify it, remove all listeners (or use weak listen

I'm working on a flash game that has developed an obvious memory leak. I do what I'm supposed to do with GC; remove all references to the object, nullify it, remove all listeners (or use weak listeners); but the leak is still present.

I've stumbled across this article: http://www.andymoore.ca/2010/03/motherfucking-as3-garbage-collection/

It claims tha开发者_StackOverflow中文版t objects that are too large will never be garbage collected. This theory fits well with my project since all of my game resides in a couple of huge MovieClips that are created and destroyed often.

Is there any merit to the claim that objects that are too large will never be garbage collected?


I've worked on multiple mid-size to large-size project and the leak you describe seems to be a problem of recursive disposal. You need to really introspect your object from the most nested item and start disposing from that point (stop, nullify, dispose bitmapdata and remove listeners).

I suggest that you take a look at those: A nice profiler: https://code.google.com/p/flashpreloadprofiler/

Quasimondo developer on the aviary suite experiencing problem with large bitmap and showing an application that simulate memory assignation: http://www.quasimondo.com/archives/000691.php http://www.quasimondo.com/examples/memoryhog.html

Also for more resources on GC issues I suggest you use the Adobe Jira and Bugbase system: https://bugs.adobe.com/

I do not think there are any merit to that claim. Also read Andy Moore comment:

So doing a quick pass of on-death = null codes, I halved my memory footprint. I was able to drop that by a further 80% by commenting out all my “.cacheAsBitmap = true” statements.


You can try using SWFWire Debugger to see exactly which objects aren't being collected.

Disclaimer: This is my own project

0

精彩评论

暂无评论...
验证码 换一张
取 消