about running identical implementations of the app in discussion in Crystal, Rust, and Nim (add C++ too, which has the same problem).
The Crystal version consistently uses 2.5 - 3.5 GB less memory for the large input numbers in the discussion, versus every other language.
Someone in the Nim community responded in the Crystal forum why, and cited the response in the Nim forum (go to end of thread) https://forum.nim-lang.org/t/4950#56891
and stated the issue with Nim was it was copying the primes array to each thread, while Crystal shares it, as it's a read only (immutable) array.
Is this the reason that the Rust version also uses so much more memory?
If so, what can be done to mitigate it, and not affect performance (the Rust version is fastest by a good measure).
The Crystal thread has gist links to the source code for all versions.
it's just a single missing closed paranthesis (between lines 205/206); I've independently come up with and made the same change and it compiles successfully. I won't be doing any performance tests on my machine here to confirm it resolves the problem.