On Mon, Aug 26, 2024 at 08:47:39AM +0000, Ian Shaw wrote:
> I'd been running a longish session of gnubg self-play when I got a crash. Is 
> this a memory error?
> 
> gnubg 3-ply wins a gammon and 2 points.
> The score (after 3428 games) is: gnubg 3-ply 2245, gnubg 0-ply 2183 (money 
> session, without Jacoby rule).
> 
> Considering move...
> (gnubg-cli:35568): GLib-ERROR **: 17:26:03.666: 
> ../glib-2.74.5/glib/gmem.c:136: failed to allocate 699016 bytes


Yes, this is a memory allocation error. Gnubg uses the GLib memory 
allocation functions and, from their documentation: "If any call to 
allocate memory using functions g_new(), g_new0(), g_renew(), 
g_malloc(), g_malloc0(), g_malloc0_n(), g_realloc(), and g_realloc_n() 
fails, the application is terminated."

The idea is that it is difficult to recover cleanly from such a 
condition and modern computers have so much memory that it will never 
happen :-).

Running a 35 games session, my process (on linux but it shouldn't matter 
much) goes from 230M to 257M, so at 3428 you may have used about 230 + 
100 * 27, or 3 GB. gnubg-cli.exe being a "large address aware" 32bits 
executable, it should be able to use 4 GB of memory on a 64bits OS but 
less than this on a 32bits one (see 
https://learn.microsoft.com/en-us/windows/win32/memory/4-gigabyte-tuning 
for explanations).

Using about 500kB-1MB per game seems a bit high but not ridiculous (the 
evaluations of all legal moves in all positions are recorded). As far as 
I know there is no memory leak in the session recording but it may not 
be used as sparingly as it could.

As a practical matter, if you need to keep the games record you should 
probably restrain the sessions to, for instance, 2000 games and collate 
the results yourself if you need more of them.

If you don't need it you can use the "set record off" CLI command or 
uncheck "Settings/Options/Other/Record all games" in the GUI.

Reply via email to