.:: Bots United ::.

.:: Bots United ::. (http://forums.bots-united.com/index.php)
-   The RealBot 'Source' (http://forums.bots-united.com/forumdisplay.php?f=52)
-   -   memory leak. (http://forums.bots-united.com/showthread.php?t=2275)

Whistler 13-07-2004 13:50

memory leak.
 
from nodemachine.cpp file:

Code:

void
cNodeMachine::FreeVisibilityTable (void)
{
  if (cVisTable)
    free (cVisTable);
}

...but I just never find it get called anywhere. and at the start of each map cNodeMachine::init() just malloc() a lot of memory so this may be a memory leak.

@$3.1415rin 13-07-2004 16:21

Re: memory leak.
 
hey stefan, here you might see the advantages of using ctors and dtors :P

Josh_Borke 13-07-2004 20:50

Re: memory leak.
 
another minor leak:
bot.cpp:64:
Code:

char *message = (char *) malloc (64 * sizeof (char));
is never freed

stefanhendriks 16-07-2004 13:25

Re: memory leak.
 
@Josh, it should be freed when the DLL is unloaded. I am not sure how to do that... Actually thats probably of very old NNBot Ditlew's Radio interception messages and stuff :)

Josh_Borke 16-07-2004 14:18

Re: memory leak.
 
yea, it's from the radio messages stuff, could you do it in Meta_Detach? along with FreeVisibilityTable? HTH

stefanhendriks 16-07-2004 14:39

Re: memory leak.
 
doh! Done.

Whistler 17-07-2004 00:22

Re: memory leak.
 
FreeVisibilityTable should be freed in ServerDeactivate().
and the Meta_Detach() isn't get called if we exit the game normally and not use metamod command to unload the plugin. The correct place to free it is in DllMain() (windows) and _fini() (linux)
also why not use "char message[64];" ? That's exactly same as the malloc thing and we don't need to care about freeing the memory

stefanhendriks 17-07-2004 09:08

Re: memory leak.
 
I don't know about 'message', it is very (very!) old code i once got from Ditlew (NNBot), so i just litterally took it over. I bet it can be improved here.

Are you sure the memory is not being freed even when exiting the game? How does metamod itself free itself then? (and all its plugins).

Whistler 17-07-2004 10:55

Re: memory leak.
 
I once added a "assert(false)" in the Meta_Detach() function and only when I use metamod command to unload the plugin it bombs out.

stefanhendriks 17-07-2004 11:34

Re: memory leak.
 
hmm, well i guess metamod needs some fix up there too then ;) Anyway, thx for the tip! I will work on it when i have time today; i have a lot of cleaning to do before my gf comes by.. :)


All times are GMT +2. The time now is 03:15.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.