it's not an oom, and it's not an infinite loop, it's just adding n constants is accidentally quadratic, [issue link](https://github.com/nim-lang/Nim/issues/16790)
do you need p to be `const`? import sequtils const n = 2000000 const list = toSeq(0..n) func f(): int = var i = 0 list[i] Run works for me