<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>SDL ttf question</title>
<description> Hi

I have made a simple application, that counts how many times you press the A button, and writes it on the TV using sdl and sdl_ttf . Unfortunetly it only works for about 3 minutes, then SDL writes:

QuoteSDL_SetError: Out of memory
SDL_SetError: SDL_UpperBlit: passed a NULL surface

Read source here

I would like to know what I have done wrong.

Thank you</description><link>http://forum.wiibrew.org/read.php?11,26577,26577#msg-26577</link><lastBuildDate>Sat, 06 Jun 2026 22:28:05 +0200</lastBuildDate>
<generator>Phorum 5.2.23</generator>
<item>
<guid>http://forum.wiibrew.org/read.php?11,26577,27671#msg-27671</guid>
<title>Re: SDL ttf question</title><link>http://forum.wiibrew.org/read.php?11,26577,27671#msg-27671</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>scanff</strong><br />The only thing different I do in my projects is initialize SDL to 24bit. I&#039;ve never tried TTF with 16bit.</div></blockquote><br />I am initializing SDL with 16bit but there is no difference in this with 24bits<br /><br />Problem is that you estinguish Wii&#039;s memory and SDL cannot load aditional data<br /><br />I made this func:<br /><pre class="bbcode">
bool ReloadImage(SDL_Surface* &imageSurface, char* fileName)
{
	SDL_FreeSurface(imageSurface); // free surface if it is not NULL
	imageSurface = NULL;
	imageSurface = load_image(fileName); // load new image - function from SDL tutorial
	return imageSurface == NULL ? false : true;
}
</pre>]]></description>
<dc:creator>Slappy</dc:creator>
<category>Coding</category><pubDate>Tue, 04 Aug 2009 15:51:33 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,26577,26698#msg-26698</guid>
<title>Re: SDL ttf question</title><link>http://forum.wiibrew.org/read.php?11,26577,26698#msg-26698</link><description><![CDATA[ <blockquote class="bbcode"><div><small>Quote<br /></small><strong>henke37</strong><br />A quick google on the function quickly explains that it returns a pointer to a new surface. And the surface is not freed for you. And you are not freeing it either. That&#039;s what I call an obvious memory leak.</div></blockquote><br />lol, how did I miss that, nice catch. After looking over my coded I noticed I am calling SDL_FreeSurface (luckily)]]></description>
<dc:creator>scanff</dc:creator>
<category>Coding</category><pubDate>Mon, 27 Jul 2009 19:10:01 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,26577,26696#msg-26696</guid>
<title>Re: SDL ttf question</title><link>http://forum.wiibrew.org/read.php?11,26577,26696#msg-26696</link><description><![CDATA[ It seems that you are right ekeeke and henke37. I added <pre class="bbcode">
if(scoret){SDL_FreeSurface(scoret);}
</pre> in the loop just before the rendering, and now SDL makes no errors :-)<br /><br />Thank you very much to you all!<br /><br />By the way, before i read your solution i made my own system that can write 3 digit numbers to the screen. What a waste of time :-P At least it was fun writing, hehe.]]></description>
<dc:creator>andersers</dc:creator>
<category>Coding</category><pubDate>Mon, 27 Jul 2009 19:05:21 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,26577,26685#msg-26685</guid>
<title>Re: SDL ttf question</title><link>http://forum.wiibrew.org/read.php?11,26577,26685#msg-26685</link><description><![CDATA[ A quick google on the function quickly explains that it returns a pointer to a new surface. And the surface is not freed for you. And you are not freeing it either. That&#039;s what I call an obvious memory leak.]]></description>
<dc:creator>henke37</dc:creator>
<category>Coding</category><pubDate>Mon, 27 Jul 2009 18:43:01 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,26577,26684#msg-26684</guid>
<title>Re: SDL ttf question</title><link>http://forum.wiibrew.org/read.php?11,26577,26684#msg-26684</link><description><![CDATA[ scoret is a SDL_Surface pointer which obviously is allocated when you call the TTF_ function<br />from what I remember, SDL surfaces are internally allocated using SDL_CreateRGBSurface (former SDL_AllocSurface) which itself do some malloc (s)<br />Obviously, if you are calling this in a loop without freeing the surface, you will most likely run out of memory sooner or later. This is probably what&#039;s happening here]]></description>
<dc:creator>ekeeke</dc:creator>
<category>Coding</category><pubDate>Mon, 27 Jul 2009 18:42:32 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,26577,26678#msg-26678</guid>
<title>Re: SDL ttf question</title><link>http://forum.wiibrew.org/read.php?11,26577,26678#msg-26678</link><description><![CDATA[ I&#039;m not sure what the issue is. Unless there&#039;s a leak I&#039;m not seeing your code should be working fine.<br /><br />My only other suggestion would be to use the latest SVN SDL version (that&#039;s what I use). It just means you&#039;ll have to get and build the libogc SVN, replace the libraries in the libogc dir with the new ones, get the SDL SVN build that and replace the SDL libs.]]></description>
<dc:creator>scanff</dc:creator>
<category>Coding</category><pubDate>Mon, 27 Jul 2009 18:13:22 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,26577,26605#msg-26605</guid>
<title>Re: SDL ttf question</title><link>http://forum.wiibrew.org/read.php?11,26577,26605#msg-26605</link><description><![CDATA[ by "initialize SDL to 24bit" you mean the bitsperpixel in <a href="http://sdl.beuc.net/sdl.wiki/SDL_SetVideoMode" rel="nofollow">SDL_SetVideoMode</a>, right?<br /><br />I tried changing the value to 24, but it still fails.]]></description>
<dc:creator>andersers</dc:creator>
<category>Coding</category><pubDate>Mon, 27 Jul 2009 00:29:36 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,26577,26604#msg-26604</guid>
<title>Re: SDL ttf question</title><link>http://forum.wiibrew.org/read.php?11,26577,26604#msg-26604</link><description><![CDATA[ The only thing different I do in my projects is initialize SDL to 24bit. I&#039;ve never tried TTF with 16bit.]]></description>
<dc:creator>scanff</dc:creator>
<category>Coding</category><pubDate>Mon, 27 Jul 2009 00:20:25 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,26577,26599#msg-26599</guid>
<title>Re: SDL ttf question</title><link>http://forum.wiibrew.org/read.php?11,26577,26599#msg-26599</link><description><![CDATA[ I&#039;m using sdl version<br /><blockquote class="bbcode"><div><small>Quote<br /></small><strong></strong><br />http://sdl-wii.googlecode.com/files/SDL%20Wii%2005-13-2009.zip</div></blockquote>
<a href="http://sdl-wii.googlecode.com/files/SDL%20Wii%2005-13-2009.zip" rel="nofollow">http://sdl-wii.googlecode.com/files/SDL%20Wii%2005-13-2009.zip</a><br />05-13-2009<br /><br /><pre class="bbcode">
TTF_RenderText_Blended( font, buffer, textColor );</pre>
gives the same error.]]></description>
<dc:creator>andersers</dc:creator>
<category>Coding</category><pubDate>Sun, 26 Jul 2009 23:48:56 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,26577,26596#msg-26596</guid>
<title>Re: SDL ttf question</title><link>http://forum.wiibrew.org/read.php?11,26577,26596#msg-26596</link><description><![CDATA[ Strange, it does not look like memory is leaking. I&#039;ve used TTF_RenderText_Blended before and there does not seem any problems with it. Try :<br /><pre class="bbcode">
scoret = 0;
scoret = TTF_RenderText_Blended( font, buffer, textColor );
if (scoret) apply_surface( 200, 20, scoret, screen );</pre><br />Also what SDL version are you using?]]></description>
<dc:creator>scanff</dc:creator>
<category>Coding</category><pubDate>Sun, 26 Jul 2009 23:17:37 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,26577,26594#msg-26594</guid>
<title>Re: SDL ttf question</title><link>http://forum.wiibrew.org/read.php?11,26577,26594#msg-26594</link><description><![CDATA[ Obviously there is a memory leak somewhere. I don&#039;t know the API, but to me it looks like you keep getting handles/pointers from TTF_RenderText_Solid, but you are never releasing them.]]></description>
<dc:creator>henke37</dc:creator>
<category>Coding</category><pubDate>Sun, 26 Jul 2009 23:08:44 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,26577,26588#msg-26588</guid>
<title>Re: SDL ttf question</title><link>http://forum.wiibrew.org/read.php?11,26577,26588#msg-26588</link><description><![CDATA[ Thank you very much, it helped somewhat. Now SDL only writes<br /><blockquote class="bbcode"><div><small>Quote<br /></small><strong></strong><br />SDL_SetError: Out of memory</div></blockquote>]]></description>
<dc:creator>andersers</dc:creator>
<category>Coding</category><pubDate>Sun, 26 Jul 2009 22:20:40 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,26577,26585#msg-26585</guid>
<title>Re: SDL ttf question</title><link>http://forum.wiibrew.org/read.php?11,26577,26585#msg-26585</link><description><![CDATA[ Probably done nothing wrong. But don&#039;t rely on a surface to be created, it can sometimes fail. Try this :<br /><pre class="bbcode">

scoret = 0;
scoret = TTF_RenderText_Solid( font, buffer, textColor );
if (scoret) apply_surface( 200, 20, scoret, screen );

</pre>]]></description>
<dc:creator>scanff</dc:creator>
<category>Coding</category><pubDate>Sun, 26 Jul 2009 22:01:29 +0200</pubDate></item>
<item>
<guid>http://forum.wiibrew.org/read.php?11,26577,26577#msg-26577</guid>
<title>SDL ttf question</title><link>http://forum.wiibrew.org/read.php?11,26577,26577#msg-26577</link><description><![CDATA[ Hi<br /><br />I have made a simple application, that counts how many times you press the A button, and writes it on the TV using sdl and sdl_ttf . Unfortunetly it only works for about 3 minutes, then SDL writes:<br /><br /><blockquote class="bbcode"><div><small>Quote<br /></small><strong></strong><br />SDL_SetError: Out of memory<br />SDL_SetError: SDL_UpperBlit: passed a NULL surface</div></blockquote><br /><a href="http://pastebin.com/f512268ce" rel="nofollow">Read source here</a><br /><br />I would like to know what I have done wrong.<br /><br />Thank you]]></description>
<dc:creator>andersers</dc:creator>
<category>Coding</category><pubDate>Sun, 26 Jul 2009 21:11:47 +0200</pubDate></item>
</channel>
</rss>