PDA

View Full Version : Kos /out of memory/kernel stack problem



Azuki
January 10th, 2006, 22:08
Well, i use Kos 1.2.0 dans DCfreedev patched, i load an .elf file to the dreamcast through serial coder's cable.

After some function calls this error happens :

KallistiOS 1.2.0: Sat Jul 12 16:52:05 2003
La Cible@amd600:/home/kos
thd: pre-emption enabled, HZ=100
maple: active drivers:
PuruPuru (Vibration) Pack: JumpPack
VMU Driver: Clock, LCD, MemoryCard
Mouse Driver: Mouse
Keyboard Driver: Keyboard
Controller Driver: Controller
DMA Buffer at ac7005a0
vid_set_mode: 640x480 NTSC
fs_romdisk: mounting image at 0x8c059f40 at /rd
dc-load console support enabled
maple: attached devices:
A0: Dreamcast Controller (01000000: Controller)
vid_set_mode: 640x480 NTSC
Requested sbrk_base 0x8d033000, was 0x8cf9d000, diff 614400
kernel panic: out of memory; about to run over kernel stack
arch: aborting the system


the source is a code testing a function by calling it in a loop something like this :


void Function{ .... };

int main(int argc, char *argv[])
{

for (unsigned int count=0; count< 10;count++)
{
Function();
}

}

the meaning of this test is to make a recursion of some functions while the user do not press a button.

I use only local variables in the function ...


what is wrong doing this ?

Vorrtexx
January 10th, 2006, 22:38
Is the function loading any images and not deleting them after it's finished processing?
Or any use of pointers that are not being freed?

Azuki
January 12th, 2006, 16:37
Hi,

The function use three types of ressource :


1) Sdl surfaces : those surfaces are declared, the BMP images loaded, and surfaces freeing at the end of the function by the SDL function " SDL_FreeSurface() " before the "return;" statement.

2) variables : only unsigned int which (i think) do not need to be freeing as its local declaration (in the beginning of the function.

3) static arrays declaring like this :

unsigned int EXEMPLE[]={value1,value2,......valueN};

the free() function seems to be called only when malloc() is used.


it's like this :


void FUNCTION()
{

SDL_Surface *surface1,*surface2 .....;

surface1=SDL_DisplayFormat(SDL_LoadBMP("/rd/My_image1.bmp"));
surface2=SDL_DisplayFormat(SDL_LoadBMP("/rd/My_image2.bmp"));
.
.
.
surfaceN=SDL_DisplayFormat(SDL_LoadBMP("/rd/My_imageN.bmp"));



unsigned int ARRAY1[]={0,4,1,0,1,2,3,4,5,4,3,2,1,0,1,2,3,4,5,6,7,8,9,1} ;
unsigned int ARRAY2[]={0,9,1,0,7,2,3,4,5,4,3,2,1,0,1,2,3,4,5,6,7,8,9,1} ;
.
.
.
unsigned int ARRAYN[]={0,9,1,0,7,2,3,4,5,4,3,2,1,0,1,2,3,4,5,6,7,8,9,1} ;



unsigned int Variable1, ....VariableN;


for (unsigned int LoopCount=0; LoopCount< 639;LoopCount++)
{
Drawing things ....
Calculations ...
}

SDL_FreeSurface(Surface1); .....SDL_FreeSurface(SurfaceN);

return;

}

BlueCrab
January 15th, 2006, 16:48
I'm willing to bet its probably the SDL surfaces. SDL is pretty buggy on the Dreamcast, and is known for leaking memory, even when you're sure you're freeing it all afterwards.

Azuki
January 17th, 2006, 18:17
Well i think you're wright, this stack problem happens when the function try to allocate new SDL_surface : Hope there's one day a bette SDL version for DC.

By the way, is there any function in KOS that could freeing this memory when SDL fails ? Perhaps i could use it to save me from memory holes.

I suppose that invoquing SDL surface loading will put BMP files directly in Vram (8 mo spacing).

Azuki
January 22nd, 2006, 15:14
OK solved it's in kos manual video section, function that clear video page

thanks all !