syzygy1 / tb

GNU General Public License v2.0
221 stars 50 forks source link

Memory leak in interface/tbcore.c #28

Closed Matthies closed 6 years ago

Matthies commented 6 years ago

Hi.

It seems that the memory allocated for struct PairsData in setup_pairs() is never freed after STOP and even after QUIT. Visible e.g. in Arena GUI that shows the engine consuming more and more memory when probing the TB. Bug or design? I would suggest some cleanup function that could be called from the engine.

syzygy1 commented 6 years ago

After "quit" the engine quits and any allocated memory will be released by the OS no matter what. However, I am reasonably sure that the engine itself releases all memory allocated by the probing code before it actually quits. (OK, that is not part of the interface/tbcore.c code, but that is not a full engine anyway. I am talking about Cfish and Stockfish.)

After "stop" no memory is deallocated because the engine will likely search another position.

The "more and more memory" consumption is not caused by Pairsdata allocations but by more and more of the TB files getting swapped into shared memory (shared with any other engines also accessing the TBs).

syzygy1 commented 6 years ago

Setting the TB path (SyzygyPath) to "" releases all memory. I think that is part of the interface/* code but I could be mistaken.

Matthies commented 6 years ago

Indeed setting the SyzygyPath to "" before closing the engine seems to free the allocated PairsData. I will use that. Thanks.