public
Created

iterator block gotcha sample code - F# equivalent

  • Download Gist
program.fs
F#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
// Learn more about F# at http://fsharp.net
open System
 
let showMemory( msg : string) =
let memory = GC.GetTotalMemory(true)
Console.WriteLine("{0, -30} {1}", msg + ":", memory)
 
let main ()=
let source = seq {0 .. 1000000}
let query = Seq.distinct source
showMemory("Before Count()")
Seq.length query |> ignore
showMemory("After Count()")
GC.KeepAlive(query)
showMemory("After query eligible for GC")
 
main()
 

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.