Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Nalimov's tablebases - memory leak

Author: Eugene Nalimov

Date: 12:49:21 08/06/99

Go up one level in this thread


All the memory is allocated through call to PvMalloc() function, that actually
calls malloc().

Look at the following routines:
(1) VInitEnumerations() - allocates enumeration tables,
(2) PutbrCreateSubtable() - called from VCreateEmptyTbTable(), allocates TB
search tables,
(3) FReadTableToMemory() - if you decide to permanently read TB into memory, and
did not specify buffer, it'll allocate it for you,
(4) Some other memory that is allocated by different routines is actually freed
by IInitializeTB(), as you can call it second time. Please look at the code
after comments "// Free memory from TB table" and "// Free compression blocks".
Just move those fragments into separate routine and call it from your code.

When you'll be done, you can send this code for me. Maybe it'll be useful for
somebody else.

Eugene

On August 06, 1999 at 15:35:32, Gerrit Reubold wrote:

>On August 05, 1999 at 22:50:11, Dann Corbit wrote:
>
>>On August 05, 1999 at 22:32:57, Robert Hyatt wrote:
>>[snip]
>>>When a program exit()'s, there is _no_ requirement that memory that was
>>>obtained via "malloc()" should be released.  The operating system should
>>>be able to clean up after a program exits.  The only exceptions are memory
>>>segments that are 'permanent' like those created via shmget().
>>>
>>>The bug isn't in Eugene's code nor in yours...  The system you are running has
>>>some sort of memory leak bug that needs a fix... and there probably is one
>>>already as this would be a _serious_ problem...
>>Since he said he was using VC++ 6, he is on NT.  NT frees memory on exit().
>>There are actually rare instances of operating systems that assume a user
>>program frees all memory it has allocated.  But that is not the problem in this
>>case.  He is probably using purify or electric fence or boundschecker or some
>>such runtime analyzer which will barf at all memory segments allocated by the
>>program but not explicitly freed.  I register an atexit() program when testing
>>crafty for leaks.  It (currently) does not have any, nor does it do any memory
>>over writes.
>
>I am on NT (and Win95/98) and the code is working fine, the OS is releasing the
>allocated memory. I should have made this explicit in my first post. However, I
>would like to free the allocated memory myself, just a habit. Does anybody know
>which variables of Eugene's probing code remain allocated when the program
>exits? If I knew which pointers to free, I would do it myself.
>
>Greetings,
>Gerrit



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.