Memory Usage


saboteur

Member
Joined
Nov 17, 2005
Messages
172
Is there a correct way for handling memory usage and does feenix / flamebird have problems freeing memory.

i have a short program which just changes the backgound image every 50 turns of a counter and after about 5 rotations memory usage on my PC increases by 1mb.

The two images i'm using are 10kb and 744bytes.

my code follows.

when using the graph=x function how do you stop displaying this particular graph.

Thanks

CODE

program bgswap;

global
int g_Bg;
int looptimer;
int choice;

begin
set_mode(320, 240, 16);
looptimer=50;
choice=1;

write_int(0,20,200,0,&looptimer);

While ( !key(_esc) )
looptimer--;
if(looptimer==1 and choice==1)
g_Bg=LOAD_PNG("logo.png");
put_screen(0, g_Bg);
choice=2;
looptimer=50;
end
if(looptimer==1 and choice==2)
g_Bg=LOAD_PNG("background2.png");
put_screen(0, g_Bg);
choice=1;
looptimer=50;
end
frame;
end

end
 
you dont need to load the images again and again.

Do something like this:
CODE
...
g_Bg1 = load_png("logo.png");
g_Bg2 = load_png("background2.png");

while( !key(_esc) )
looptimer--;
if( looptimer == 1 )
if( choice == 1 )
put_screen(0, g_Bg1);
choice=2;
else
put_screen(0, g_Bg2);
choice=1;
end;
looptimer=50;
end;
frame;
end

and start using code tags for code please!
 
Quiest said:
you dont need to load the images again and again.

Do something like this:
CODE
...
g_Bg1 = load_png("logo.png");
g_Bg2 = load_png("background2.png");

while( !key(_esc) )
looptimer--;
if( looptimer == 1 )
if( choice == 1 )
put_screen(0, g_Bg1);
choice=2;
else
put_screen(0, g_Bg2);
choice=1;
end;
looptimer=50;
end;
frame;
end

and start using code tags for code please!
Or possibly

CODE
...
g_Bg[0] = load_png("logo.png");
g_Bg[1] = load_png("background2.png");

while( !key(_esc) )
looptimer--;
if( looptimer == 1 )
if( choice == 1 )
put_screen(0, g_Bg[0]);
choice=2;
else
put_screen(0, g_Bg[1]);
choice=1;
end;
looptimer=50;
end;
frame;
end
 
Last edited by a moderator:
sam fisher said:
Quiest said:
you dont need to load the images again and again.

Do something like this:
CODE
...
g_Bg1 = load_png("logo.png");
g_Bg2 = load_png("background2.png");

while( !key(_esc) )
looptimer--;
if( looptimer == 1 )
if( choice == 1 )
put_screen(0, g_Bg1);
choice=2;
else
put_screen(0, g_Bg2);
choice=1;
end;
looptimer=50;
end;
frame;
end

and start using code tags for code please!
Or possibly

CODE
...
g_Bg[0] = load_png("logo.png");
g_Bg[1] = load_png("background2.png");

while( !key(_esc) )
looptimer--;
if( looptimer == 1 )
if( choice == 1 )
put_screen(0, g_Bg[0]);
choice=2;
else
put_screen(0, g_Bg[1]);
choice=1;
end;
looptimer=50;
end;
frame;
end





Thanks for that peeps. It's been a steep learning curve but I think i'm finaly getting the hang of it.

I think i may start documenting what i've done so far and how i've done it ( a kind of idiots guide to feenix ) so other people won't have to bother the forum like I have.

Sorry about the code tags also.

cheers
 
Last edited by a moderator:
Naw, the extra E is for the hyper version.

it bounces around alot more, then clears of to the local filling station to get the some munchies :)
 
Back
Top