<?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>Meh Blog! &#187; Torque 2D for iPhone</title>
	<atom:link href="http://www.codexsoftware.co.uk/blog/tag/torque-2d-for-iphone/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codexsoftware.co.uk/blog</link>
	<description>Computer topics and random rants!</description>
	<lastBuildDate>Wed, 30 Jun 2010 21:31:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Fixing the iTGB 1.2 Memory Leak</title>
		<link>http://www.codexsoftware.co.uk/blog/computers/programming/fixing-the-itgb-1-2-memory-leak/</link>
		<comments>http://www.codexsoftware.co.uk/blog/computers/programming/fixing-the-itgb-1-2-memory-leak/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 15:12:38 +0000</pubDate>
		<dc:creator>arcana</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Garage Games]]></category>
		<category><![CDATA[iTGB]]></category>
		<category><![CDATA[Memory Leak]]></category>
		<category><![CDATA[Torque]]></category>
		<category><![CDATA[Torque 2D for iPhone]]></category>

		<guid isPermaLink="false">http://www.codexsoftware.co.uk/blog/?p=79</guid>
		<description><![CDATA[I recently purchased Torque 2D for the iPhone and came across a large memory leak in their iTGB 1.2 release whenever I ran the game on my iPhone 3G.  I had a very basic platform game running with no engine modifications to the source code at all.  The game would run for about 4 minutes [...]]]></description>
			<content:encoded><![CDATA[<p>I recently purchased Torque 2D for the iPhone and came across a large memory leak in their iTGB 1.2 release whenever I ran the game on my iPhone 3G.  I had a very basic platform game running with no engine modifications to the source code at all.  The game would run for about 4 minutes before running out of memory and exiting.  <span id="more-79"></span>If I opened Organizer in Xcode and looked at the Console tab I&#8217;d see this:</p>
<blockquote><p>Tue Aug 25 21:52:15 unknown SpringBoard[23] : Memory level is urgent (9%) and there are no background apps to ask to exit.<br />
Tue Aug 25 21:53:18 unknown SpringBoard[23] : Application &#8216;MyGame&#8217; exited abnormally with signal 11: Segmentation fault<br />
Tue Aug 25 21:53:19 unknown ReportCrash[4565] : Saved crashreport to /Library/Logs/CrashReporter/LowMemory-2009-08-25-215318.plist using uid: 0 gid: 0, synthetic_euid: 0 egid: 0</p></blockquote>
<p>As I was a complete noob to the engine, I assumed I&#8217;d done something wrong.  I checked my scripts and made sure I wasn&#8217;t allocating memory anywhere and that I wasn&#8217;t doing anything silly like executing scripts within a loop.  Eventually I ran out of ideas and reverted to iTGB 1.1, which didn&#8217;t suffer from the memory leak.</p>
<p>I decided I&#8217;d rather use the latest and greatest offering so I thought I&#8217;d revisit iTGB 1.2. I recompiled TGEGame with <strong>PUAP_OPTIMIZE</strong> and <strong>PUAP_SCRIPT_CHANGE</strong> so the options set are now</p>
<pre class="brush: plain;">
__MACOSX__
TORQUE_DISABLE_MEMORY_MANAGER
TORQUE_PLAYER
TORQUE_RELEASE
PUAP_SCRIPT_CHANGE
PUAP_OPTIMIZE
USE_COMPONENTS
</pre>
<p>I *may* have added the &#8216;R&#8217; on to the end of <strong>TORQUE_DISABLE_MEMORY_MANAGER</strong>. There was a typo in some of the projects. Mostly on release configs but I can&#8217;t remember which ones.</p>
<p>Then I opened the Xcode_iPhone project and switched to the <strong>iTGB_Script_Optimize</strong> target. In release build I made sure these were set:</p>
<pre class="brush: plain;">
__IPHONE__
TORQUE_DISABLE_MEMORY_MANAGER
TORQUE_PLAYER
TORQUE_RELEASE
PUAP_SCRIPT_CHANGE
PUAP_OPTIMIZE
USE_COMPONENTS
</pre>
<p>I&#8217;m pretty sure I added the &#8216;R&#8217; on the end of <strong>TORQUE_DISABLE_MEMORY_MANAGER</strong> this time.</p>
<p>Then I made sure <strong>Compiler</strong><strong> Version</strong> was set to <strong>GCC 4.0</strong> and under <strong>Linking</strong> I changed <strong>C++ Standard Library Type</strong> from <strong>Static</strong> to <strong>Dynamic</strong>.</p>
<p>I also set my <strong>iPhone OS Deployment Target</strong> and <strong>Base SDK</strong> to <strong>iPhone OS 3.0</strong>. You probably don&#8217;t need to do that but I&#8217;m mentioning it anyway. If you&#8217;re having trouble compiling for 3.01 even though you have the latest non-beta iPhone SDK then you may need to create a symbolic link from your Terminal / shell.</p>
<pre class="brush: plain;">
cd /Developer/Platforms/iPhoneOS.platform/DeviceSupport
ln -s 3.0 3.0.1
</pre>
<p>I don&#8217;t have the big memory leak any more <img src='http://www.codexsoftware.co.uk/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.codexsoftware.co.uk/blog/computers/programming/fixing-the-itgb-1-2-memory-leak/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
