iedoc
iedoc

Reputation: 2324

Can you expect flash/as3 player to eventually garbage collect?

So I'm quite aware of flash/as3 garbage collecting causing memory leaks, and all the questions on the net.

Our software runs a swf, that loads in other swfs, videos, and images. It is expected to run a week without being restarted. generally, the player barely makes it a week without crashing from using too much memory. the swf will load in other assets based on the time of day, or if the schedule has changed. I wrote a simple resource manager so that it keeps track of what is used and what isn't, and will unload and set the unused assets to null. it does this unused check every hour, but it still seems that memory still doesn't go down after these assets are unloaded, and the memory leak continues to grow.

What I'm wondering, and can't seem to find, is can you expect flash to for SURE eventually release memory that is unused? or is there a possibility that flash may NEVER release unused memory?

Upvotes: 2

Views: 105

Answers (3)

Niallith
Niallith

Reputation: 146

It's really hard to find where memory-leaks come from without tools. During game developpement I use Flash Builder Profiler, allow me to see if all my objects are destroyed when they are supposed to be.

In your case I would take a look at Adobe Scout : http://gaming.adobe.com/technologies/scout/

Introduction to adobe scout: https://www.youtube.com/watch?v=yUHipsoGB2U

Using those tools during and after game developpement are the way to deal with memory-leaks.

Upvotes: 3

Pikamander2
Pikamander2

Reputation: 8299

Flash should be garbage collecting things that are no longer referenced. Is it possible that there are still references to whatever you're trying to garbage collect? You'll need to use removeEventListener() anytime that you've used addEventListener() to ensure that all of the references get deleted.

So, if you add an event listener to an object:

foo.addEventListener(Event, functionName)

Then you'll need to remove the reference when you're deleting the object:

foo.removeEventListener(Event, functionName)

Upvotes: 1

Cadin
Cadin

Reputation: 4629

It should be garbage collecting. Are you sure you're not inadvertently holding onto a reference to the unused objects? It's pretty easy to forget to remove an event listener, which will prevent an object from being collected when the GC runs.

Upvotes: 0

Related Questions