Mono 2.4 still leaking like a sieve
How fast are hash tables in Mono 2.4 compared to .NET 4? An excellent question but one which led us to another trivial program that leaks memory on Mono but not on .NET (we previously gave a simple stack implementation written in F# that leaked memory on Mono 2.2).
We tried to use the following benchmark program to measure Mono's performance when filling a hash table from empty with float keys and values:
for i in 1..10 do let t = System.Diagnostics.Stopwatch.StartNew() let m = System.Collections.Generic.Dictionary() let mutable x = 0.0 for i=1 to 10000000 do m.[x] <- x x <- x + 1.0 printfn "m[42] = %g" m.[42.0] printfn "Took %gs\n" t.Elapsed.TotalSeconds
Here's the output of that program on Mono 2.4:
$ mono HashTableBenchmark.exe m[42] = 42 Took 3.45099s m[42] = 42 Took 3.2431s m[42] = 42 Took 3.39288s m[42] = 42 Took 27.2352s Unhandled Exception: System.OutOfMemoryException: Out of memory at (wrapper managed-to-native) object:__icall_wrapper_mono_array_new_specific (intptr,int) at System.Collections.Generic.Dictionary`2[System.Double,System.Double].Resize () [0x00000] at System.Collections.Generic.Dictionary`2[System.Double,System.Double].set_Item (Double key, Double value) [0x00000] at <StartupCode$HashTableBenchmark>.$Program.main@ () [0x00000]
Even more surprisingly, this program still dies with out of memory even if we explicitly Clear the hash table after every iteration!
Comments
Post a Comment