Closed azrafe7 closed 10 years ago
The ones in Emitter and BitmapText shouldn't be recreated because the render functions are inlined. Perhaps I am mistaken but I believe they work that way on all targets.
Also, LayerList
sorts in the opposite order of Scene.layerSort
so I've added a layerSort
function.
:thumbsup:
Shouldn't those sort functions be inlined too?
So next step can probably be: "Avoid usage of Dynamic
and Std.is()
".
Inlining the sort functions won't do any because they get called from the Array.sort function. It's not super fast but generally the layer list is small so it doesn't cause a performance hit.
As for avoiding Dynamic
and Std.is()
see #208.
Oooh... Nice! You're a step ahead man!
Though I think that the anonymous function thing needs to be investigated more. I tested a simple demo with a GraphicList
in Scout and got:
renderList(function (g:Graphic) ...)
renderList(renderBlit, ...)
I'm surprised Flash doesn't inline the function like Neko/C++. Seems weird to have a function that just calls another function but I guess we can do that...
Also, thanks for making me aware of Adobe Scout. I've been wondering if there was a decent Flash profiler out there and I guess there is. :)
I finally figured out why inlines aren't working in Flash. OpenFL disables them in debug mode... Check your debug.hxml
generated file and you'll find -no-inline
.
Build it for release and the memory issues should disappear.
Aha!
@MattTuttle has already replaced the one for sorting layers, but there's a bunch of them in other sections of the engine code (Emitter, BitmapText, ...) that could possibly be called/recreated every frame. We should replace them with non-anoymous ones (and maybe inline them if suitable).
Also... I know it's a recent commit, but this https://github.com/HaxePunk/HaxePunk/blob/dev/com/haxepunk/debug/LayerList.hx#L158 should, in some way, make use of
Scene.layerSort()
.