Message Board


Message Board > Fenix / Bennu / Gemix / DIV > Does Bennu automatically free memory?

October 19, 2010, 11:12
Dennis
どこかにいる
2092 posts

i.e.

Fenix code:
Process SpaceShip( int x, int y, int angle, int maxspeed, int maxturnspeed)
Public // Declare public variables here
Private // Declare private variables here
    int speed;
Begin // Start the main processcode
    graph = new_map(20,20,8);
    map_clear(0,graph,rgb(0,255,255));
    Loop
        speed+=key(_up)*(speed<maxspeed)-key(_down)*(speed>-maxspeed);
        angle+=(key(_left)-key(_right))*maxturnspeed;
        advance(speed);
        frame;
    End
OnExit // Start the exit code
    unload_map(0,graph);
End // End the main processcode


In this example there is OnExit code that frees memory of the graph. But since the process dies, the pointer to the process is gone, so I assumed that allocated memory for Spaceship.graph is free as well. Why would ANYONE need the memory if the process is killed?


PS: I can't use "code=bennu" only "code=fenix" in BB code. Bennu totally messes up the layout of the entire website. (firefox)
____________
Kwakkel
#
October 20, 2010, 17:59
Sandman
F3n!x0r
1194 posts

The allocated memory for the local variable int graph is freed. The graph is not automatically unloaded because Fenix/Bennu do not have a garbage collector for graphs. This would be insane to implement in Fenix/Bennu, because memory altering functions like memcopy would screw with that. Fenix/Bennu do not support objects and are rather C-like.
____________
BennuWiki
Yes, my avatar has grey borders in IE (so get a decent browser)
ROOFLEZ ROOFLEZ
#
October 21, 2010, 13:47
Dennis
どこかにいる
2092 posts

Ok, thanks for the info.

I think I'll keep 'm in a struct.

PS: I added WaveID and unload_wav(); in the wiki.

[Edited on October 21, 2010 by Dennis]
____________
Kwakkel
#

Message Board > Fenix / Bennu / Gemix / DIV > Does Bennu automatically free memory?

Quick reply


You must log in or register to post.
Copyright © 2005 Booleansoup.com
Questions? Comments? Bug reports? Contact us!