That is actually interesting. Usually, the garbage collector should collect all these strings after some time, but for some reason, it doesn’t here (although I’m testing this with Crystal 1.8.0).
You can even manually trigger the collection with GC.collect just before the sleep 0.1 line, after which everything works perfectly fine.
Maybe there’s still some issue with Windows and Fibers, but I don’t think that this behavior is intended. I used some longer strings (without manual GC call) and I stopped the program after it claimed more than 4 GB of my RAM…
It’s marked as “Closed”, but the discussion is quite lengthy and often mentioned by other issues (even recently), so maybe that issue might need to be reopened (at least for Windows).
As mentioned, as a workaround you could run GC.collect from time to time (like every 5 minutes), but yeah, this issue needs to be fixed (or at least a clarification what’s going on).
I would rather open a new issue, since this is platform-specific. We’re working now on ironing Windows right now, so this is the right moment to put that issue (can’t promise a fix soon though).