Adobe Air AS3, with a window, profiler offers library code

My application creates a window with several groups. When the window is closed, the window and its descendants are not collected by the GC.

The Flash Builder profiler helped me find and remove event listeners to such an extent that I cannot detect the problem, because it points to event listeners added from the code of the Window.as library.

In particular, comparing Loitering Objects before opening a window and after closing a window and selecting the MyWin class (1 instance):

MyPackageName.MyWin (10 paths)

10x next line:

Function [savedThis] 569222 GCRoot: Yes bytes: 308

Clicking each "function" in the "Method" panel, I see the following 10 at the top of each "function":

 spark.components:Window:creationCompleteHandler() Window.as line 2610 spark.components:Window:creationCompleteHandler() Window.as line 2613 spark.components:Window:creationCompleteHandler() Window.as line 2616 spark.components:Window:creationCompleteHandler() Window.as line 2619 spark.components:Window:creationCompleteHandler() Window.as line 2625 spark.components:Window:creationCompleteHandler() Window.as line 2639 spark.components:Window:creationCompleteHandler() Window.as line 2636 Spark.components.supportClasses:SkinnableComponent:attachSkin() SkinnableComponent.as line 694 Spark.components:SkinnableContainer:partAdded() SkinnableContainter.as line 959 Spark.components:SkinnableContainer:partAdded() SkinnableContainter.as line 957 

They are all called from MyWin.initialize () in some way.

I deleted every event listener created by my code and deleted all transitions. but still unable to understand the meaning of this and how I can manage the window. Any help would be greatly appreciated as I struggled for several days.

+4
source share
2 answers
 You can try to use System.pauseForGCIfCollectionImminent(1) http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/System.html#pauseForGCIfCollectionImminent%28%29 or try to use System.gc() in this way private var numCollected; uint = 0; private function gCollect(): void { addEventListeners(Event.ENTER_FRAME, onEFGCollect); } private function onEFGCollect(event: Event): void { numCollected++; System.gc(); if(numCollected > 2) removeEventListeners(Event.ENTER_FRAME, onEFGCollect); } 

we use System.gc () twice in separate frames only because to collect an object it needs to mark all of them as collected - and only after that System.gc () can collect objects.

+1
source

As far as I know, the best way is to make sure that all links to the window in question are set to null. I had studied this before and could not find a direct way to get the garbage collector to work immediately.

0
source

Source: https://habr.com/ru/post/1438510/


All Articles