Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1735
XamLinearGauge MemoryLeak that can kill the computer
posted

We encountered a mysterious memory leak that when triggered would start using up the memory non-stop, and that if you didn't attention it would render the computer unusable forcing the user to do a hard shutdown. In around 15-30 seconds used up all RAM Memory available (in computers with 32 GBs of RAM).

We had a really hard time troubleshooting this issue, until we realized it was due to the XamLinearGauge control.

We had a custom control using the XamLinearGauge, we were binding the MinimumValue and MaximumValue, something similar to this:

    <ig:XamLinearGauge MinimumValue="{Binding MinValue}" MaximumValue="{Binding MaxValue}"   />

It seems there is a bug inside the XamLinearGauge, if you use a MinimumValue too close to the MaximumValue it fails and creates, if you are lucky, a System.OutOfMemory Exception, and otherwise freeze the computer by continuously requesting more memory.

If you use values like:

MinimumValue="0.649999"
MaximumValue="0.650001"

On the Designer you get a System.OutMemoryException. If you are binding the values of those properties, your application gets trapped in a requesting memory loop.

We found that the threshold for the error was 0.5, if you used values separate by less than 0.5 it fails.

From our troubleshooting, we believe the control gets trapped in some sort of loop where it allocates more and more memory for the ticks. We saw with a memory profiler a huge sparse List<Tuple<double,double>> object that we were not allocating.

We had to remove the control an do our own implementation. I believe this a bug of the control.