Fix arithmetic overflow when memory dump has too many objects. (#4928)
authorjjshao <44551173+JJLovesLife@users.noreply.github.com>
Fri, 13 Sep 2024 16:45:41 +0000 (00:45 +0800)
committerGitHub <noreply@github.com>
Fri, 13 Sep 2024 16:45:41 +0000 (09:45 -0700)
I have a dump with GiB size, and has more than 200M objects, and
encountered arithmetic overflow when run `dumpheap -live -stat`.

src/Microsoft.Diagnostics.ExtensionCommands/LiveObjectService.cs

index a77b997eba1acac6d6bc9a8e2c5f5d0f7de8db3e..3dee6f8fbdbd75618ab7f513ff28d12228f1ee35 100644 (file)
@@ -85,7 +85,7 @@ namespace Microsoft.Diagnostics.ExtensionCommands
                     }
                     else
                     {
-                        Console.WriteLine($"Calculating live objects: {live.Count:n0} found - {(maxCount - todo.Count) * 100 / (float)maxCount:0.0}% complete");
+                        Console.WriteLine($"Calculating live objects: {live.Count:n0} found - {(maxCount - todo.Count) * 100.0f / maxCount:0.0}% complete");
                     }
 
                     maxCount = Math.Max(maxCount, todo.Count);