I'm dumb and I have a memory problem that I'm not equipped to understand:
The problem resides in this project: https://github.com/LokeX/voracityII
in the files:
game.nim
play.nim
eval.nim
misc.nim
stat.nim
They will compile and run as intended with:
nim r stat
The program hogs memory till the system runs out:
I'm on Windows 11
The hogging stems primarily - as far as I can tell - from calls to:
proc evalPos
in line 209
in eval.nim
Admittedly: it's not a trivial problem, but: the functions are pure and uses only the standard library
In my naivity I thought it would be simple for the GC to clean up as the stack unwinds - but hey what do I know.
For context: the code plays a boardgame
Is there a kind soul out there that can explain to me the error of my ways?
Per
OMG
You listed markAndSweep and I thought, yeah I might have missed that one. So I tried - and the problem went away...
I'm so happy!
Thanks Araq
Would be nice though if the default GC could do it - but I'll take it!
Would be nice though if the default GC could do it - but I'll take it!
Well, it's a serious bug we have to fix. Please try to reduce the program to a test case that still has the same problem.
So, I managed to cook...
My solution is here:
https://github.com/LokeX/voracityII/tree/main/memtest
The text files and some of the code are needed to generate:
a board, a deck and a player.
Without which: no sauce
The test has a player draw some cards and evaluate them in perpetuity.
Without the call to evalBlues(), or when compiled with a GC other than arc/orc, the program maintains steady state.
The evalBlues call chain is pure, which at least makes things easier to reason about.
I hope this will be helpful