hi Guys,
Two questions here, if I may:
1. Is there a tool out there by which I can monitor my app to see if I leak memory? (on top of e.g. process monitoring, etc, so some "Haxe specific" tool I mean here. Or an analyzer maybe -bottlenecks, potential leaks, coding style, etc-)
2. Found something interesting and I don't know what causes the issue.
SHORT VERSION:When calling localBitmapDataVar.dispose() of a -monster- object instance, all monsters are removed from stage, not just the one which called dispose on itself. Why?
LONG VERSION:I have an array storing the instances of a Sprite-extending class. It's about spawning several from the same monster and keep track of them:
var myFoo : Array<MySpriteClass> = null;
When I add items to it, I do this:
myFoo.add(new MySpriteClass());
openfl.Lib.current.stage.addChild(myFoo[lastitem]); //should add openfl.Lib... etc?
For remove, I do this:
myFoo.remove(objMySpriteClass); //where objMyS... is a reference to the monster object.
//As I did not have a better idea -yet-, my Game instance gets it back as a function param from the caller (the call is something like "MyParentGameObj.callback_function(this, otherparams);")
I have a destructor function in my 'MySpriteClass'. I call this function from 'Game' before I remove/"nullify" a particular monster-object (ie it gets shot, so monster is out of game).
The issue comes here. I destroy stuff in my function (local timer & event listeners), all goes well, except for one thing!
MyBitmapDataVar.dispose();
This variable stores the by-frame animation of the monster. I draw frames in stage update with TileSheet.drawTiles.
If I call the code line above, ALL my monsters disappear from the screen(stage), instead of the one which should.
* New monsters spawn as intended after (and before) this
* 'MyBitmapDataVar' is a class-level local (private), non-static variable
* The Asset / graphics is common of course, as monsters are -kinda- identical
My expectation was, all mobs (object instances) create their own BitmapData object and store "their own" animation frames, so if I dispose the one related to that particular object, that only that monster disappears.
What did I miss learning Haxe & openFL?
[FYI - If I remove the dispose() line, everything goes fine: one monster is removed, spawning goes on as intended, etc.]
Thank you for all the trouble in advace, and for reading this long post :)
Cheers,
Mark