<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>OpenLayer font loading uses lots of memory</title>
		<link>http://www.allegro.cc/forums/view/591247</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Fri, 04 May 2007 23:45:46 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Just this line of code:<br /><span class="source-code"><span class="k1">static</span> TextRenderer normalTextRenderer<span class="k2">(</span><span class="s">"Fonts/CHERI.TTF"</span>, <span class="n">55</span>, <span class="n">35</span>, Rgba<span class="k2">(</span><span class="n">0</span>.<span class="n">0f</span>, <span class="n">0</span>.<span class="n">0f</span>, <span class="n">0</span>.<span class="n">9f</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span></span></p><p>Is taking up about 30MB of memory, and it&#39;s a pretty simple font. Is this normal? What can I do about it?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vasco Freitas)</author>
		<pubDate>Thu, 03 May 2007 02:57:32 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I don&#39;t think this&#39;d have much to do with it, but what font is it?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Ceagon Xylas)</author>
		<pubDate>Thu, 03 May 2007 21:46:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Just some font I got at dafont.com (I don&#39;t remember the name), but this seems to happen with all fonts, I tried 4 different fonts. The more complex the font though, the more memory it seems to use. But even the simplest ones I tried occupy 20-30MB. </p><p>I&#39;d really appreciate some help on this, the game I&#39;m making isn&#39;t supposed to take up more than 32MB <img src="http://www.allegro.cc/forums/smileys/undecided.gif" alt=":-/" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vasco Freitas)</author>
		<pubDate>Thu, 03 May 2007 22:46:39 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Which version of OpenLayer do you use? Compiled with which compiler? Do you use internal text rendering or GlyphKeeper?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (tobing)</author>
		<pubDate>Thu, 03 May 2007 23:37:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I have a WIP version from about 5-8 months ago (after a certain version globally defined bitmaps stopped appearing, so I&#39;ve stopped updating since). The compiler is gcc 3.4.2 (mingw-special). I guess I use internal text rendering, because I don&#39;t define a GlyphKeeper type.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vasco Freitas)</author>
		<pubDate>Thu, 03 May 2007 23:59:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I don&#39;t know much about the state of OL of that time... I can only suggest you try to use the current SVN with the most recent allegroGL, and compile OL with define USE_NEW_TTF set, so the internal text renderer will be used instead of GlyphKeeper. That&#39;s at least what I do, and I have just checked that my memory consumption grows by about 600kB when I load a TextRenderer object. I have built with MSVC 7.1, but that should not make such a huge difference. </p><p>For the problem of globally defined bitmaps disappearing, that&#39;s somewhat strange and if it occurs with the current SVN I could try to help finding what&#39;s wrong there.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (tobing)</author>
		<pubDate>Fri, 04 May 2007 00:32:41 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Is taking up about 30MB of memory...
</p></div></div><p>
How do you know that? how can you measure it?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Paul whoknows)</author>
		<pubDate>Fri, 04 May 2007 00:41:17 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I compare the amount of memory the process uses with and without the font loaded, in the Windows Task Manager. I know that&#39;s probably not the best way to do it, but in this case the problem seems obvious.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vasco Freitas)</author>
		<pubDate>Fri, 04 May 2007 00:57:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I don&#39;t know open layer, but could it perhaps be rendering the font to a bitmap, and so needing to store the rendered font and if the font has a lot of characters (excess unicode pages?) or rendered at large size then that might explain it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Druss)</author>
		<pubDate>Fri, 04 May 2007 05:02:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Well, I don&#39;t know how OpenLayer stores the font, I don&#39;t load the fonts too big in size (55 pixels height), so there&#39;s no reason to save them bigger. It&#39;s surely not excess unicode pages, they usually don&#39;t have many characters. I even tried one font file that&#39;s only 9KB large.</p><p>Does this happen with anyone else?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vasco Freitas)</author>
		<pubDate>Fri, 04 May 2007 06:31:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If you only have 32 MB of ram to play around with, i would recommend using plain allegro, or something even simpler, as that is a painfully low limit (silly really).</p><p>As i understand it, the font is rendered to a texture (which is then rendered as a texture on a quad). I don&#39;t think 30MB is that unreasonable. 55 is pretty big, and the texture has to contain all the characters...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jonatan Hedborg)</author>
		<pubDate>Fri, 04 May 2007 16:59:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Vasco: I would offer to have a try to compile your sources on my machine, with my versions of the libraries and try it out. You don&#39;t use many other libs, I hope? If you&#39;re willing to send me sources and data, just zip them and send my a PM for my mail address.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (tobing)</author>
		<pubDate>Fri, 04 May 2007 17:46:26 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Jonatan Hedborg: I meant 32MB of video memory. The font should be on the video memory right? (Hope I&#39;m not saying something stupid)</p><p>I think anything above 3MB is unreasonable. A 1024 x 768 image should be about 3,2MB (right?), and all letters of a font that size surely don&#39;t take all that up.</p><p>tobing: Thanks for offering your help. All your need to do is run this simple code, with the font I&#39;ve attached:</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="p">#include &lt;OpenLayer.hpp&gt;</span></td></tr><tr><td class="number">2</td><td>&#160;</td></tr><tr><td class="number">3</td><td><span class="k1">using</span> <span class="k1">namespace</span> ol<span class="k2">;</span></td></tr><tr><td class="number">4</td><td>&#160;</td></tr><tr><td class="number">5</td><td><span class="k1">int</span> main<span class="k2">(</span><span class="k2">)</span> <span class="k2">{</span></td></tr><tr><td class="number">6</td><td>&#160;</td></tr><tr><td class="number">7</td><td>    <span class="k1">if</span><span class="k2">(</span>Setup::SetupProgram<span class="k2">(</span><span class="k2">)</span> <span class="k3">=</span><span class="k3">=</span> <span class="k1">false</span><span class="k2">)</span> <span class="k2">{</span></td></tr><tr><td class="number">8</td><td>        <a href="http://www.allegro.cc/manual/allegro_message" target="_blank"><span class="a">allegro_message</span></a><span class="k2">(</span><span class="s">"Error loading OpenLayer library!"</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">9</td><td>        <a href="http://www.delorie.com/djgpp/doc/libc/libc_298.html" target="_blank">exit</a><span class="k2">(</span><span class="k3">-</span><span class="n">1</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">10</td><td>    <span class="k2">}</span></td></tr><tr><td class="number">11</td><td>&#160;</td></tr><tr><td class="number">12</td><td>    <span class="k1">if</span> <span class="k2">(</span>Setup::SetupScreen<span class="k2">(</span><span class="n">320</span>, <span class="n">200</span>, WINDOWED, <a href="http://www.allegro.cc/manual/desktop_color_depth" target="_blank"><span class="a">desktop_color_depth</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">)</span> <span class="k3">=</span><span class="k3">=</span> <span class="k1">false</span><span class="k2">)</span><span class="k2">{</span></td></tr><tr><td class="number">13</td><td>       <a href="http://www.allegro.cc/manual/allegro_message" target="_blank"><span class="a">allegro_message</span></a><span class="k2">(</span><span class="s">"Error setting graphics mode!"</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">14</td><td>       <a href="http://www.delorie.com/djgpp/doc/libc/libc_298.html" target="_blank">exit</a><span class="k2">(</span><span class="k3">-</span><span class="n">1</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">15</td><td>    <span class="k2">}</span></td></tr><tr><td class="number">16</td><td>&#160;</td></tr><tr><td class="number">17</td><td>&#160;</td></tr><tr><td class="number">18</td><td>    <span class="c">// Remove this line to compare //</span></td></tr><tr><td class="number">19</td><td>    <span class="k1">static</span> TextRenderer normalTextRenderer<span class="k2">(</span><span class="s">"BADABB__.TTF"</span>, <span class="n">55</span>, <span class="n">35</span>, Rgba<span class="k2">(</span><span class="n">0</span>.<span class="n">0f</span>, <span class="n">0</span>.<span class="n">0f</span>, <span class="n">0</span>.<span class="n">9f</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">20</td><td>&#160;</td></tr><tr><td class="number">21</td><td>    <span class="k1">while</span> <span class="k2">(</span><span class="k3">!</span><a href="http://www.allegro.cc/manual/key" target="_blank"><span class="a">key</span></a><span class="k2">[</span>KEY_ESC<span class="k2">]</span><span class="k2">)</span><span class="k2">{</span></td></tr><tr><td class="number">22</td><td>&#160;</td></tr><tr><td class="number">23</td><td>    <span class="k2">}</span></td></tr><tr><td class="number">24</td><td>&#160;</td></tr><tr><td class="number">25</td><td>    <span class="k1">return</span> <span class="n">0</span><span class="k2">;</span></td></tr><tr><td class="number">26</td><td><span class="k2">}</span></td></tr><tr><td class="number">27</td><td><a href="http://www.allegro.cc/manual/END_OF_MAIN" target="_blank"><span class="a">END_OF_MAIN</span></a><span class="k2">(</span><span class="k2">)</span></td></tr></tbody></table></div></div><p>

On my system, <i>with</i> the font loaded the process occupies 54.640MB, <i>without</i> the font loaded, 27.420MB.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vasco Freitas)</author>
		<pubDate>Fri, 04 May 2007 20:32:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>hmm. yes, you are correct of course. My bad <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /><br />But how is it possible to know how much is uploaded to the video card? Afaik, there is no way to know how much video memory is used. And i think openlayer/openGL moves around textures if there is no more room on the video card, so you shouldn&#39;t worry about it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jonatan Hedborg)</author>
		<pubDate>Fri, 04 May 2007 20:36:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Tested with your font, it also uses about 600kB extra memory... using GlyphKeeper with pure allegro, it takes 300kB extra memory...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (tobing)</author>
		<pubDate>Fri, 04 May 2007 20:51:02 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Are you sure the font was loaded? Because, that&#39;s the extra memory I get if the font file isn&#39;t there.</p><p>I tried with OpenLayer&#39;s latest update with no success.</p><p>I&#39;ve attached the project folder I use for the test case, with the Code::Blocks project file. I&#39;d appreciate it if anyone could try it out. <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /></p><p>EDIT: Anybody? <img src="http://www.allegro.cc/forums/smileys/undecided.gif" alt=":-/" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Vasco Freitas)</author>
		<pubDate>Fri, 04 May 2007 23:45:46 +0000</pubDate>
	</item>
</rss>
