gnugo-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gnugo-devel] Memory leak analyse


From: Gunnar Farnebäck
Subject: Re: [gnugo-devel] Memory leak analyse
Date: Sun, 06 Mar 2005 13:59:53 +0100
User-agent: EMH/1.14.1 SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.3 Emacs/21.3 (sparc-sun-solaris2.9) MULE/5.0 (SAKAKI)

QingYu Ma wrote:
> There is memory leak in the 773 lines of dragon.c. 
> 
> "  if (dragon2 != NULL)
>       free(dragon2);
> [...]
> this function was called in the second time, the memory that was
> requested in the first time was freed by free(); go on and on, when
> this function was called at last time, memory that was requested by
> malloc()was not freed.

This is not a memory leak in the sense that we always have a pointer
to the memory and will continue to use it as long as the program runs.
When the program exits we rely on the operating system to reclaim the
memory. This is done also for other pieces of memory like the cache
for read results.

> On the other hand, the prototype of malloc() is void *malloc(size_t
> size), I think we should do forcible type change.

The very idea of the pointer to void type is to allow a safe
conversion to any other pointer type without the need for an explicit
cast.

> The standard use of malloc() is int *p = (int *)malloc(sizeof(int)*length).

No, it's not. It may be common but after the introduction of the C89 C
standard a better construction is p = malloc(sizeof(*p) * length).

> I want to known the way that two GnuGo play game each other in the Windows.

Presumably either of twogtp, twogtp-a, twogtp.py, and twogtp.pike in
the interface/gtp_examples directory should work, assuming that you
have Perl (for the two first), Python, or Pike installed on your
computer. I don't use Windows myself but maybe those on the list who
do can tell what works for them.

/Gunnar




reply via email to

[Prev in Thread] Current Thread [Next in Thread]