<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Armetiz - Thomas Tourlourat - CV Ingénieur Informatique &#187; Debug</title>
	<atom:link href="http://www.armetiz.info/tag/debug/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.armetiz.info</link>
	<description>Ingénieur Informatique - Lyon</description>
	<lastBuildDate>Thu, 09 Sep 2010 13:31:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Récursion infinie en Flash</title>
		<link>http://www.armetiz.info/recursion-infini-en-flash/</link>
		<comments>http://www.armetiz.info/recursion-infini-en-flash/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 08:44:19 +0000</pubDate>
		<dc:creator>Thomas Tourlourat</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Debug]]></category>
		<category><![CDATA[Développement]]></category>
		<category><![CDATA[Error]]></category>

		<guid isPermaLink="false">http://www.armetiz.info/?p=1392</guid>
		<description><![CDATA[
public function fooLoop &#40;&#41; : void
&#123;
   //Pre traitement
   fooLoop &#40;&#41;;
   //Post traitement
&#125;

Voici le corps d&#8217;une fonction récursive. 
Lorsque la pile est pleine, une jolie erreur du type StackOverFlowError est déclenchée.
Ce qui est intéressant de voir, c&#8217;est le comportement du Player et des navigateurs lorsque l&#8217;on traite cette erreur pour [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> fooLoop <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span>
<span style="color: #000000;">&#123;</span>
   <span style="color: #009900;">//Pre traitement</span>
   fooLoop <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
   <span style="color: #009900;">//Post traitement</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Voici le corps d&#8217;une fonction <a href="http://fr.wikipedia.org/wiki/R%C3%A9cursivit%C3%A9">récursive</a>. </p>
<p>Lorsque la pile est pleine, une jolie erreur du type <a href="http://help.adobe.com/fr_FR/AS3LCR/Flash_10.0/flash/errors/StackOverflowError.html">StackOverFlowError</a> est déclenchée.</p>
<p>Ce qui est intéressant de voir, c&#8217;est le comportement du Player et des navigateurs lorsque l&#8217;on traite cette erreur pour relancer la fonction récursive.</p>
<p>Voici le code utilisé :</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span>xml <span style="color: #004993;">version</span>=<span style="color: #990000;">&quot;1.0&quot;</span> encoding=<span style="color: #990000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Application xmlns<span style="color: #000000; font-weight: bold;">:</span>mx=<span style="color: #990000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> 
	layout=<span style="color: #990000;">&quot;absolute&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Script<span style="color: #000000; font-weight: bold;">&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;!</span><span style="color: #000000;">&#91;</span>CDATA<span style="color: #000000;">&#91;</span>
			<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> hack <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span>
			<span style="color: #000000;">&#123;</span>
				hack <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">click</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">void</span>
			<span style="color: #000000;">&#123;</span>
				<span style="color: #0033ff; font-weight: bold;">try</span>
				<span style="color: #000000;">&#123;</span>
					hack <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
				<span style="color: #000000;">&#125;</span>
				<span style="color: #0033ff; font-weight: bold;">catch</span> <span style="color: #000000;">&#40;</span>e<span style="color: #000000; font-weight: bold;">:</span> <span style="color: #004993;">Error</span><span style="color: #000000;">&#41;</span>
				<span style="color: #000000;">&#123;</span>
					<span style="color: #004993;">click</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
				<span style="color: #000000;">&#125;</span>
			<span style="color: #000000;">&#125;</span>
		<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#93;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;/</span>mx<span style="color: #000000; font-weight: bold;">:</span>Script<span style="color: #000000; font-weight: bold;">&gt;</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Button <span style="color: #004993;">click</span>=<span style="color: #990000;">&quot;click ()&quot;</span> label=<span style="color: #990000;">&quot;Nuked !&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;/</span>mx<span style="color: #000000; font-weight: bold;">:</span>Application<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>Avec Windows, en utilisant IE le navigateur monte en charge en utilisant la mémoire. Ce qui a pour conséquence logique de remplir le fichier d&#8217;échange. Une fois que la mémoire disponible est sèche, un mécanisme que je n&#8217;explique pas libère de la mémoire et le script continu son exécution.</p>
<p>Contrairement à Firefox qui après 400Mo d&#8217;utilisation mémoire, se positionne en &#8220;Ne réponds pas&#8230;&#8221; et se freeze de lui même.</p>
<p>Si vous voulez voir ce que cela donne, voici l&#8217;application.<br />
Pensez à surveiller l&#8217;utilisation de votre mémoire <img src='http://www.armetiz.info/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />

<object width="400" height="100">
<param name="movie" value="http://www.armetiz.info/wp-content/uploads/2009/10/Recucivity.swf"></param>
<param name="quality" value="high"></param>
<param name="wmode" value="window"></param>
<param name="menu" value="false"></param>
<param name="bgcolor" value="#FFFFFF"></param>
<embed type="application/x-shockwave-flash" width="400" height="100" src="http://www.armetiz.info/wp-content/uploads/2009/10/Recucivity.swf" quality="high" bgcolor="#FFFFFF" wmode="window" menu="false" ></embed>
</object>
</p>
<h3>L&#8217;interet</h3>
<p>Outre le fait de pouvoir faire joujou, ce script peut-être intéressant pour réaliser des traitements récursifs qui sont justement trop importants.<br />
En, effet, vous pouvez le combiner à une <strong>variable statique</strong> pour continuer le traitement lorsque l&#8217;erreur de débordement est déclenchée.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.armetiz.info/recursion-infini-en-flash/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
