Well I've done some more work and testing and there does seem to be a
limit to the number of objects that Away3DLite can have added and
removed over time. I've been through everything removing event
listeners, setting event listeners to weak references, killing all
tweens and it made no difference. The crash seemed to happen at about
28Mb of memory on the statsviewer, every time.

I began implementing Li's suggestion of re-using objects and there was
a point during testing where memory reached 50Mb and there was no
crash. I've now got all my objects in a re-usable queue and memory is
sitting nicely at around 8Mb for most of the game which is great.

So thanks Li for the solution but I still think there may be some kind
of issue to watch out for in the API when creating and destroying
1000's of objects over time.



On Jun 1, 10:20 am, robbie <[email protected]> wrote:
> Thanks Li
>
> The object re-use is a good idea but it looks like I need to do a bit
> more work managing my objects too. I'll keep you posted.
>
> cheers
> Robbie
>
> On Jun 1, 3:39 am, Li <[email protected]> wrote:
>
> > If you use the AwayStats (or Mr. Doob's stats) you will be able to monitor
> > memory use in your app. Your memory is probably rising on the creation of
> > each object until it reaches a critical state and crashes your app. You need
> > to properly release the memory used for an object when you remove it. This
> > could be probably done by properly destroying the removed objects and
> > removing any reference that exists to them. Only in this case will Flash's
> > garbage collector properly renew the memory used for this object. I'm sure
> > someone could be more precise about this topic and explain it better to you,
> > but I'm pretty sure you are having a memory management issue.
>
> > It might also be a good idea to reuse objects and have a limit of objects
> > that can appear at the same time. For example, suppose you choose a max. of
> > 100 objects that can appear at the same time. You initially create these 100
> > objects and then select which come in and which go out. When an object goes
> > out of the scene, you have it available for reuse and no one needs to know
> > it is the same object.
>
> > AwayStats will help you see if you solved your problem or not.
>
> > hth!
>
>

Reply via email to