Autor Tema: [BUG] Memory leak in path_find? [FIXED]  (Leído 7785 veces)

Eckolin

  • Newbie
  • *
  • Mensajes: 12
  • Karma: 5
[BUG] Memory leak in path_find? [FIXED]
« en: Enero 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.
Código: [Seleccionar]
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
« última modificación: Enero 17, 2010, 08:33:26 pm por Sandman »

SplinterGU

  • Hero Member
  • *****
  • Mensajes: 12534
  • Karma: 370
Re: [BUG] Memory leak in path_find?
« Respuesta #1 en: Enero 14, 2010, 02:16:03 am »
Don't must... but it seem have a memory leak...
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

Windgate

  • Hero Member
  • *****
  • Mensajes: 2930
  • Karma: 124
    • TRINIT Asociación de Informáticos de Zaragoza
Re: [BUG] Memory leak in path_find?
« Respuesta #2 en: Enero 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...
Iván García Subero. Programador, profesor de informática, monitor de actividades culturales y presidente de TRINIT Asociación de Informáticos de Zaragoza. http://trinit.es

SplinterGU

  • Hero Member
  • *****
  • Mensajes: 12534
  • Karma: 370
Re: [BUG] Memory leak in path_find?
« Respuesta #3 en: Enero 15, 2010, 08:31:51 pm »
I think that I already fix it... you have a huge sample for test it? thanks...
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

SplinterGU

  • Hero Member
  • *****
  • Mensajes: 12534
  • Karma: 370
Re: [BUG] Memory leak in path_find?
« Respuesta #4 en: Enero 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.
« última modificación: Enero 15, 2010, 09:42:38 pm por SplinterGU »
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

Windgate

  • Hero Member
  • *****
  • Mensajes: 2930
  • Karma: 124
    • TRINIT Asociación de Informáticos de Zaragoza
Re: [BUG] Memory leak in path_find?
« Respuesta #5 en: Enero 15, 2010, 11:35:04 pm »
Citar
my 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
Iván García Subero. Programador, profesor de informática, monitor de actividades culturales y presidente de TRINIT Asociación de Informáticos de Zaragoza. http://trinit.es

SplinterGU

  • Hero Member
  • *****
  • Mensajes: 12534
  • Karma: 370
Re: [BUG] Memory leak in path_find?
« Respuesta #6 en: Enero 16, 2010, 01:22:15 am »
wait... 44 millons in lot of minutes...
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

SplinterGU

  • Hero Member
  • *****
  • Mensajes: 12534
  • Karma: 370
Re: [BUG] Memory leak in path_find?
« Respuesta #7 en: Enero 16, 2010, 01:41:29 am »
I think that other memory leak is present... not 100% fixed... with you sample windgate...
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

osk

  • Hero Member
  • *****
  • Mensajes: 516
  • Karma: 52
Re: [BUG] Memory leak in path_find?
« Respuesta #8 en: Enero 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.

Windgate

  • Hero Member
  • *****
  • Mensajes: 2930
  • Karma: 124
    • TRINIT Asociación de Informáticos de Zaragoza
Re: [BUG] Memory leak in path_find?
« Respuesta #9 en: Enero 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
Iván García Subero. Programador, profesor de informática, monitor de actividades culturales y presidente de TRINIT Asociación de Informáticos de Zaragoza. http://trinit.es

Sandman

  • Sr. Member
  • ****
  • Mensajes: 298
  • Karma: 48
Re: [BUG] Memory leak in path_find?
« Respuesta #10 en: Enero 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. A more awesome version of this was devised by a fellow Dutchman named Dijkstra.
-- Sandman

Windgate

  • Hero Member
  • *****
  • Mensajes: 2930
  • Karma: 124
    • TRINIT Asociación de Informáticos de Zaragoza
Re: [BUG] Memory leak in path_find?
« Respuesta #11 en: Enero 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...
Iván García Subero. Programador, profesor de informática, monitor de actividades culturales y presidente de TRINIT Asociación de Informáticos de Zaragoza. http://trinit.es

Drumpi

  • Hero Member
  • *****
  • Mensajes: 6185
  • Karma: 157
  • Odio el periodo "entre proyectos"
    • La web de Drumpi
Re: [BUG] Memory leak in path_find?
« Respuesta #12 en: Enero 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?
Hala, como con 1001 procesos sólo va a 9 FPS, vamos a meterle 32 veces más, a ver si revienta.
(Drumpi epic moment)

SplinterGU

  • Hero Member
  • *****
  • Mensajes: 12534
  • Karma: 370
Re: [BUG] Memory leak in path_find?
« Respuesta #13 en: Enero 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...
Download Lastest BennuGD Release: http://www.bennugd.org/node/2

SplinterGU

  • Hero Member
  • *****
  • Mensajes: 12534
  • Karma: 370
Re: [BUG] Memory leak in path_find?
« Respuesta #14 en: Enero 17, 2010, 08:27:37 pm »
well, now fixed!

thanks for report...
Download Lastest BennuGD Release: http://www.bennugd.org/node/2