I'm sorry for making that much posts on my first day after signing up, but I have been testing several other Nim implementations and I thought this would also be interesting. I made a similar post today on https://forum.nim-lang.org/t/7709#48912
I encountered the following program: https://rosettacode.org/wiki/N-queens_problem#Nim , which basically tries to solve the N-queens problem. If I choose a too high N value, my RAM gets filled up really quickly. On my machine (8GB RAM) using GC the maximum N I can use is 14 or 15, less if not using a GC.
I don't understand why this happens. I thought it would be related to lines 18-20, but I'm not sure. Does anyone know what happens?
yes it's not the most memory efficient solution. i believe i did one of these using bitsets but i can't find it. at n=15 there are almost 2.3 million solutions so the data structure you use to hold a solution better be small. if you're representing a solution as a seq[int] with length 15 and maybe capacity twice that, i dont know, that's over 500MB right there.
i'm seeing 9685 MB peak memory though, so clearly some room for improvement, see what you can do!