i have datagroup compoenent in adobe air application , have used custom itemrenderer in it, attached source code of itemrenderer attached profiling of it,
question: when come other module module have datagroup @ time again create objects itemrender , previous object of itemrender wont released.
if have idea, please suggest me
<?xml version="1.0" encoding="utf-8"?> <s:itemrenderer xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" autodrawbackground="false" buttonmode="true" click="clickhandler(event)" mousechildren="false" rollout="rollouthandler(event)" rollover="rolloverhandler(event)" removedfromstage="itemrenderer1_removedfromstagehandler(event)" creationcomplete="itemrenderer1_creationcompletehandler(event)"> <fx:script> <![cdata[ import cox.xxxxxxxxxxxxxxx.event.thumbevent; import mx.events.flexevent; protected function image_completehandler(event:event):void { consoleutils.logit(" thumbimage.mxml :image_completehandler - "); image.removeeventlistener(event.complete, image_completehandler); fadein.target=image; fadein.play(); } protected function clickhandler(event:mouseevent):void { owner.dispatchevent(new thumbevent("itemclick", data, itemindex)); } protected function rolloverhandler(event:mouseevent):void { owner.dispatchevent(new thumbevent("itemrollover", data, itemindex)); } protected function rollouthandler(event:mouseevent):void { owner.dispatchevent(new thumbevent("itemrollout", data, itemindex)); } protected function itemrenderer1_removedfromstagehandler(event:event):void { this.removeeventlistener(event.removed_from_stage, itemrenderer1_removedfromstagehandler); this.removeeventlistener(mouseevent.roll_out, rollouthandler); this.removeeventlistener(mouseevent.roll_over, rolloverhandler); this.removeeventlistener(mouseevent.click, clickhandler); this.removeallelements(); } protected function itemrenderer1_creationcompletehandler(event:flexevent):void { this.removeeventlistener(flexevent.creation_complete, itemrenderer1_creationcompletehandler); image.source="test.png"; //image.addeventlistener(event.complete, image_completehandler); } ]]> </fx:script> <fx:declarations> <s:fade id="fadein" alphafrom="0" alphato="1"/> </fx:declarations> <s:bitmapimage id="image" horizontalalign="center" smooth="true" smoothingquality="high" verticalalign="middle"/> </s:itemrenderer>
snapshot of profiling
as can see, in profile, have 21 orphan objects won't recyle , profiling shows me @ saved @ line no 12 while line no 12 creation_complete event , have removed it.
thanks in advance
i have used datagroup
parent component , have define above itemrenderer in itemrenderer
property of datagroup
, , in dispose function have define datagroup.itemrenderer
null in datagroup
. eligible gc. , see no instance of itemrenderer in memory.
Comments
Post a Comment