From: jjshao <44551173+JJLovesLife@users.noreply.github.com> Date: Fri, 13 Sep 2024 16:45:41 +0000 (+0800) Subject: Fix arithmetic overflow when memory dump has too many objects. (#4928) X-Git-Tag: accepted/tizen/unified/20241231.014852~39^2^2~16 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b120f1ca4fc9b28dda8930b8c2323d48cdc37e44;p=platform%2Fcore%2Fdotnet%2Fdiagnostics.git Fix arithmetic overflow when memory dump has too many objects. (#4928) I have a dump with GiB size, and has more than 200M objects, and encountered arithmetic overflow when run `dumpheap -live -stat`. --- diff --git a/src/Microsoft.Diagnostics.ExtensionCommands/LiveObjectService.cs b/src/Microsoft.Diagnostics.ExtensionCommands/LiveObjectService.cs index a77b997eb..3dee6f8fb 100644 --- a/src/Microsoft.Diagnostics.ExtensionCommands/LiveObjectService.cs +++ b/src/Microsoft.Diagnostics.ExtensionCommands/LiveObjectService.cs @@ -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);