Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Dynamic memory allocation question

Author: Robert Hyatt

Date: 14:27:01 12/03/02

Go up one level in this thread


On December 03, 2002 at 11:40:57, Daniel Clausen wrote:

>On December 03, 2002 at 11:33:40, Robert Hyatt wrote:
>
>[snip]
>
>>>The class could internally for example take chunks of a preallocated array and
>>>use that for storing the moves. (the size of the chunk being
>>>MAX_NUMBER_OF_MOVES_IN_A_POSITION) This way you have a clean interface and all
>>>the hacks like the aforementioned MAX number and/or array-bounds checking is
>>>inside the class, where you can easily change it later in the development
>>>process.
>>
>>You still have to do garbage-collection as you can malloc and free out-of-order
>>and end up with a fragmented memory space in the array...
>
>I think we're not talking about the same thing.
>
>There are people who have a global array of moves (well, their engines...) and
>for each search-call, they use a fixed number of slots in this array. You do
>something similar, but use only as many slots as needed, since you do some
>house-keeping and store the starting-index per ply separately)
>
>My point was that I can do exactly the same but hide it behind a
>class-interface.

Sure, but he specifically asked about dynamic allocation of data space, and
whether you do that with malloc/free, or you create a large static array and
do it yourself, you have the same garbage-collection issue.  What I do in
Crafty is not considered to be a dynamic allocation approach.  It is a static-
sequential scheme that doesn't need any GC...

>
>Sargon



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.