|
Tempy111, Sr. Member
Posted: 27 January 2016 12:59 PM Total Posts: 133
While I thought I was clearing everything from Memory, it seams I’m not As a result, memory usage is increasing as the game plays level after level.
All meshs are being removed from the scene via the removeChild
Then the meshs via the array that stores the links are setting them to null to clear the mesh itself
Then the arrays are cleared. This should remove the mesh data from memory
Event Listeners are removed, SpriteSessions are removed and the scene is cleared and removed.
But the memory still goes up, so the meshs, i’m guessing, the main things still in memory and aren’t being cleared..
Any ideas on better memory clearing practices with this?
I should add that for the Away3D project stats, Mesh count isn’t going up, T Elements and R Elements are also the same.
|
cyberix3d, Jr. Member
Posted: 28 January 2016 10:54 AM Total Posts: 34
[ # 1 ]
|
Tempy111, Sr. Member
Posted: 28 January 2016 04:52 PM Total Posts: 133
[ # 2 ]
yep. I kinda do though Arrays aren’t the best for Memory use and speed. It tweaked things a bit more and are better but I’ll probably need to do some more later on.
|
therealloft, Member
Posted: 01 February 2016 01:07 AM Total Posts: 65
[ # 3 ]
have you tried disposing all of the models in the scene? i use this
for(var i:int = 0; i < view.scene.numChildren; i++){ view.scene.getChildAt(i).disposeWithChildren(); }
|
Tempy111, Sr. Member
Posted: 01 February 2016 08:18 AM Total Posts: 133
[ # 4 ]
thanks but that is Away3D 4.X as the software tag on this topic says, I use Away3D 3.X (3.6)
|
Tempy111, Sr. Member
Posted: 09 March 2016 10:44 AM Total Posts: 133
[ # 5 ]
Back to this issue.. I guess some of this I’m talking about right now is going to be version generic.
The Player Model is the same in each map. So do I need to reload I on each map and get rid of it when the level/map is completed in ready for the next.
First thought was no. I can keep it. then I looked again.. the destroyer for each level should be doing a complete job, but I don’t think it does. It Does, however, remove the camera, the scene, the lightpoint and removes the view, which is then set up again each level. However, I believe this is pointless to remove each time. while it should be cleaning, if it’s not, or if a bit is left, it would lead to increased memory usage with each level, which I’m still getting (though I can take 4 or 5 levels to notice a large increase). As these objects are recreated each level, why bother to remove them? a lot of objects like the player, which is on each level, can just stay there because nothing changes apart from there location. this should improve load times AND memory usage by completely using it.
however, in practice, this failed a fair bit. textures which were still being unloaded and reloaded didn’t load, the background scene kept the old image of the last rendered frame etc.. all messy. So it seams either I did something amazingly wrong in soo little change, or it doesn’t work like that. either I can live with.
Another questions come up too. in the old days, I would have put in some checking code to make sure objects which are off the visible screen are not rendered, but I believe Away3D manages this automatically? is this the case or have I got things completely confused?
|
Tempy111, Sr. Member
Posted: 15 March 2016 07:55 PM Total Posts: 133
[ # 6 ]
Been using Monster Debugger as an AS3 debugger… not bad though I still don’t quite understand it all, but I noticed when I was destroying the one level to make way for the next, memory usage was NOT going down at all. This means when the next level starts, even with reusing as much as I think I can, memory usage goes up. As the levels go by, frame rate drops and the game becomes unplayable (and incompletable) by level 10.
the destroyer gets rid of meshs via removechild (from the scene) and making the pointers etc null which I don’t think is good enough but.. what else… I know it’s a very old story but oh well..
|
Tempy111, Sr. Member
Posted: 17 March 2016 09:22 PM Total Posts: 133
[ # 7 ]
I wonder if any one can comfirm or deny this theory.
I have a Variable, we’ll call it RabbitMesh for now. It stores the Mesh for a Rabbit.
when a level is loaded, the RabbitMesh is set. when the level ends, it is cleaned. when the next level starts, it is set again.
BUT, when It is cleaned, what is going on is the reference is being removed so it should be clear for the GC to clean it.. but if the GC doesn’t kick it before the next level loads, the new Mesh being loaded doesn’t REPLACE the old one, but instead uses up MORE memory. Now there is an active reference, the GC doesn’t clean up the old one. thus leading to twice the space being used up then what should be.
It’s a theory which sounds like a mixture of possible and stupid.. just wonder if anyone can comfirm or deny (for a fact) this?
|
Hector, Sr. Member
Posted: 13 December 2016 02:22 PM Total Posts: 137
[ # 8 ]
Any progress on this? I’m also having the same problem with an old Away3D 3.6 project. We need to add/remove lots of objects and we end up with a big memory leak.
|
Tempy111, Sr. Member
Posted: 13 December 2016 02:31 PM Total Posts: 133
[ # 9 ]
nope, not at all.
basically, it’s a real bugger. kinda a ‘Do all that you know, and try all that you don’t’ situation i’m afraid
|