Posts Tagged ‘ debug ’

Firefox hanging on Debug

launch firefox -> about:config
Modify the value of  dom.ipc.plugins.timeoutSecs to -1

This helps hanging of firefox after default 45 seconds while debugging with break points in Flex

Advertisements

Using garbage collection

The below component can be used for monitoring/debugging the memory usage in your application. This also portrays about how to force the garbage collection or emptying the memory usage.

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml&#8221; layout=”horizontal” >
<mx:Script>
<![CDATA[
import flash.events.TimerEvent;
[Bindable]
private var minmem:Number = 0;
[Bindable]
private var totalmem:Number = 0;
[Bindable]
private var maxmem:Number = 0;
private var timer:Timer;
private function doGarbageCollection() : void
{
var lc1:LocalConnection = new LocalConnection();
var lc2:LocalConnection = new LocalConnection();
try
{
lc1.connect(“empty”);
lc2.connect(“empty”);
}
catch (e:Error) {}
}
public function start() : void
{
timer = new Timer(500);
timer.addEventListener(TimerEvent.TIMER, timerHandler, false, 0, true);
timer.start();
}
public function stop() : void
{
totalmem = 0;
timer.stop();
timer.removeEventListener(TimerEvent.TIMER, timerHandler);
timer = null;
}
private function timerHandler(e:TimerEvent) : void
{
totalmem = System.totalMemory;
maxmem = Math.max(maxmem, totalmem);
if (minmem == 0)
{
minmem = totalmem;
}
else
{
minmem = Math.min(minmem, totalmem);
}
}
]]>
</mx:Script>
<mx:Form>
<mx:FormItem label=”Minimum : “>
<mx:TextInput id=”minimum” editable=”false” text=”{minmem}” />
</mx:FormItem>
<mx:FormItem label=”Current : “>
<mx:TextInput id=”current” editable=”false” text=”{totalmem}”/>
</mx:FormItem>
<mx:FormItem label=”Maximum : “>
<mx:TextInput id=”maximum” editable=”false” text=”{maxmem}”/>
</mx:FormItem>
<mx:HBox>
<mx:Button label=”Monitor” id=”monitors” toggle=”true” click=”{monitors.selected ? start() : stop() }”/>
<mx:Button label=”Clear” click=”doGarbageCollection()”/>
</mx:HBox>
</mx:Form>
</mx:Application>

Debug Flash Player Capabilities

The below code debugs the capabilities of system, might be useful for debugging.

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml&#8221; layout=”horizontal”
initialize=”init()”>
<mx:Script>
<![CDATA[
import flash.system.Capabilities;
import mx.utils.ObjectUtil;
private function init() : void
{
var _capObj:Array = new Array();
capability.dataProvider = objectToArray(Capabilities);
}
private function objectToArray(cap:Class) : Array
{
var capObj:Object = ObjectUtil.getClassInfo(cap);
var _capArr:Array = new Array();
for each (var _capPropObj:Object in capObj.properties)
{
if (_capPropObj.localName != “prototype”)
{
var capProp:Object = new Object();
capProp.Capability = _capPropObj.localName;
capProp.Value =Capabilities[capProp.Capability]
_capArr.push(capProp);
}
}
return _capArr;
}
]]>
</mx:Script>
<mx:DataGrid id=”capability” width=”100%” height=”100%” />
</mx:Application>