Access violation with SDL_RenderText

Johan Granberg lijat.meREM at OVE.gmail.com
Fri Oct 27 09:46:51 PDT 2006


mike wrote:

> Hi!
> 
> I'm doing some GUI stuff with SDL and I got those constantly changing
> values that I need to draw on the screen. The idea (if you don't know SDL)
> is that you create a new surface (a bitmap) every time the value changes,
> draw it to the screen and then delete the bitmap after drawing.
> 
> In pseudo code:
> 
> ' surface = RenderText(value); // <- This function returns a pointer to a
> new surface (a struct)
> ' DrawSurface(surface);
> ' UpdateScreen();
> ' FreeSurface(surface);
> 
> Now that works so far. The problem is that my program crashes after some
> time - about two minutes when I'm constantly moving the mouse, forcing the
> GUI to redraw (access violation in the RenderText() line). Memory usage
> goes up a little, about 4k every 10-15 seconds, which makes me a bit
> suspicious, since I'm not newing anything at all, besides the surface I
> get returned from RenderText() which I delete anyway, using the
> FreeSurface() function.
> 
> So my question: Has anybody of you had this problem? Or any ideas? Could
> that be a GC issue? Maybe the GC wants to free something that doesn't
> exist anymore? I have no idea what's going wrong, so if someone could give
> me a hint I'd be very glad.
> 
> -Mike
> 

I don't know what is wrong but i had a similar problem myself also using
SDL. I think it can bee related to string handling but is not sure, try
calling gcfullcolect every frame and see if it helps, I got my memory leaks
down to a tickle that way.



More information about the Digitalmars-d-learn mailing list