Created
January 20, 2011 19:11
-
-
Save tlwalker/788418 to your computer and use it in GitHub Desktop.
iterator block gotcha sample code - F# equivalent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment