Memory will be released eventually, but not immediately after each iteration. But it should be released long before memory starts to fill up. (See Tracing garbage collection - Wikipedia)
I tried your code on my machine and didn’t see any problem. map(sim, 1:30)
runs in about 100sec, and the memory usage fluctuates around 200MB the whole time. Can you give an minimal working example that actually demonstrates your problem?