Bennu Game Development

English Forums => Suggestions => Topic started by: Eckolin on January 13, 2010, 11:48:35 PM

Title: [BUG] Memory leak in path_find? [FIXED]
Post by: Eckolin on January 13, 2010, 11:48:35 PM
Is path_find causing a memory leak?

This program seems to use increasing amounts of memory while it runs.

program Path_leak;
   import "mod_map";
   import "mod_path";
   import "mod_grproc";
   import "mod_key";
begin
   graph=new_map(20,20,8);
   while (!key(_esc))
       path_find(0,graph,0,0,1,1,0);
       path_getxy(&x,&y);
       frame(1);
   end
end

Title: Re: [BUG] Memory leak in path_find?
Post by: SplinterGU on January 14, 2010, 02:16:03 AM
Don't must... but it seem have a memory leak...
Title: Re: [BUG] Memory leak in path_find?
Post by: Windgate on January 14, 2010, 10:30:55 AM
path_find ( ) doesn't work fine... I tried it any times and it uses LOTS of memory and is very limited. If anyone wants to check the source and fix it... Any tree algorithm could work...

But only one question Eckolin:

path_find ( ) must be used out of the LOOP and then use parth_getxy ( ) to get all positions of the path. If you use path_find () inside of the LOOP to update the path it is ok, but be sure that parameters are changed for the new x,y...
Title: Re: [BUG] Memory leak in path_find?
Post by: SplinterGU on January 15, 2010, 08:31:51 PM
I think that I already fix it... you have a huge sample for test it? thanks...
Title: Re: [BUG] Memory leak in path_find?
Post by: SplinterGU on January 15, 2010, 09:30:38 PM
fixed...

my test give me, 44 millons of frames without memory leak.

but I need a heavy test... with walls... I think that others memory leak can be happen... this implementation don't is 100% nice.
Title: Re: [BUG] Memory leak in path_find?
Post by: Windgate on January 15, 2010, 11:35:04 PM
Quotemy test give me, 44 millons of frames without memory leak.

Oh my lol... Here is an example with 1024 enemys solving a laberint... Each enemy re-calculate path_find on each frame, nowadays the fps can not afford more than 5 fps on my laptop.

The game has all .dll of an old version of Bennu, if you want to overwrite the dlls and check the improve come on... :P

(This example was made by a very young student last year).

DOWNLOAD: http://trinit.es/DescargaDirecta/Bennu2D/Alumnos/Victor%20Lopez/Victor%20IA%200.3.zip (http://trinit.es/DescargaDirecta/Bennu2D/Alumnos/Victor%20Lopez/Victor%20IA%200.3.zip)
Title: Re: [BUG] Memory leak in path_find?
Post by: SplinterGU on January 16, 2010, 01:22:15 AM
wait... 44 millons in lot of minutes...
Title: Re: [BUG] Memory leak in path_find?
Post by: SplinterGU on January 16, 2010, 01:41:29 AM
I think that other memory leak is present... not 100% fixed... with you sample windgate...
Title: Re: [BUG] Memory leak in path_find?
Post by: osk on January 16, 2010, 12:51:25 PM
I can only say that if there is not any possible solution finding a path, path_find() hangs itself, always.
Title: Re: [BUG] Memory leak in path_find?
Post by: Windgate on January 16, 2010, 05:35:46 PM
I have been thinking on a new path_find ( ) function made with Bennu... From the current pixel you launch one searcher to up,down,left,right pixels. The searchers do the same and launch more searchers avoiding the checked pixles (As is made on IA pathfinding). When a searcher finds the goal he returns a value and kill all active searchers... ¿What do you think about it?

The number of process could be really big on big maps, but it could be limited with a parameter or something. I have this idea cause I still don't know well how to compile dlls on Bennu :P
Title: Re: [BUG] Memory leak in path_find?
Post by: Sandman on January 17, 2010, 11:55:05 AM
Doing that with processes is a huge overkill, it needs to be done with two lists: checked nodes and to-be-checked nodes and then using one function iteratively is the best thing. This search is called breadth-first search (http://en.wikipedia.org/wiki/Breadth-first_search). A more awesome version (http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm) of this was devised by a fellow Dutchman named Dijkstra.
Title: Re: [BUG] Memory leak in path_find?
Post by: Windgate on January 17, 2010, 12:07:11 PM
Yes, the best thing is to use any of these algotithms. path_find use something like that, but I think it is "bad-written" or something...
Title: Re: [BUG] Memory leak in path_find?
Post by: Drumpi on January 17, 2010, 03:18:46 PM
But, why don't make a mod with A* algorithm? it isn't better than Dijstra?
I used Dijstra in some exercises and is better to use it with a "net" with a few points than in a pixels map, don't it?
Title: Re: [BUG] Memory leak in path_find?
Post by: SplinterGU on January 17, 2010, 05:04:44 PM
yes, very nice... but first need add all nodes and all conections...

the bug in current mod_path, isn't very critical, have solution... I only need change some structs...
Title: Re: [BUG] Memory leak in path_find?
Post by: SplinterGU on January 17, 2010, 08:27:37 PM
well, now fixed!

thanks for report...
Title: Re: [BUG] Memory leak in path_find? [FIXED]
Post by: Windgate on January 18, 2010, 12:32:41 AM
lol Im waiting to test it over my example, and path_find is also usefull on 3D terrains in Bennu 3D, so there are always a bitmap associated. Very thanks Splinter :D
Title: Re: [BUG] Memory leak in path_find? [FIXED]
Post by: josebita on January 18, 2010, 08:14:02 AM
Thanks, Splinter.
I already uploaded your changes to my PPA.
Title: Re: [BUG] Memory leak in path_find? [FIXED]
Post by: Windgate on January 18, 2010, 07:45:53 PM
But where is the new mod_path.dll, must I wait for the next Bennu RC?
Title: Re: [BUG] Memory leak in path_find? [FIXED]
Post by: josebita on January 18, 2010, 07:50:45 PM
it's on my ppa :)
Title: Re: [BUG] Memory leak in path_find? [FIXED]
Post by: Windgate on January 18, 2010, 09:26:35 PM
You mean only for Linux? I have a new HP laptot with Windows 7 and a fucking recovery system and I think I will be some time without using Linux...
Title: Re: [BUG] Memory leak in path_find? [FIXED]
Post by: josebita on January 18, 2010, 09:40:17 PM
Well, you'll have to wait for Splinter to release it or compile it yourself, then.
Title: Re: [BUG] Memory leak in path_find? [FIXED]
Post by: SplinterGU on January 18, 2010, 09:46:40 PM
thanks...

I have problems with windows compilations... I was must compile manually openssl in win32, and I was modify files in openssl products... and now I can't generate shared lib of libogg in win32...

shit!
Title: Re: [BUG] Memory leak in path_find? [FIXED]
Post by: Windgate on January 18, 2010, 10:29:39 PM
Sorry can't help you by now :'(

...but some weeks ago I was talking with Sandman and with some help I could compile succesfully his network dll, maybe he could help with this Splinter? All was made with CodeBlocks.

Private message to Sandman or something?

PD: I owe you the Linux magazine with the Bennu item Splinter :P
Title: Re: [BUG] Memory leak in path_find? [FIXED]
Post by: SplinterGU on January 18, 2010, 10:44:06 PM
Oh, no, no codeblocks, thanks...

PD: Oh, thanks... josebita already buy it for me... thanks anyway... :D