xamarin / SignaturePad

MIT License
245 stars 150 forks source link

Multiple instances of SignaturePad causes UWP crash #116

Closed jneno closed 6 years ago

jneno commented 6 years ago

When a UWP application instantiates an instance of the SignaturePad and the frame is navigated away from, it appears that the underlying InkCanvas is never disposed, even when the containing page no longer exists and nothing else apparently holds a reference to a SignaturePad.

A memory profile using dotMem shows an instance for each visit to a frame containing a SignaturePad still residing in memory but it doesn't seem to think it is a leak (that they could be garbage collected). Explicitly calling garbage collection (GC.Collect()) does not work around it.

To help show the issue, I created a simple 2-page app at:

https://github.com/jneno/SignaturePadLeakDemo

When Page 2 is navigated to, it creates a SignaturePad instance (page caching is left at the default disabled configuration). If you navigate back and forth between Pages one and two 128 times, the app crashes with this out of memory error:

System.OutOfMemoryException: 'Insufficient memory to continue the execution of the program.
mattleibow commented 6 years ago

I am happy to say that this bug has been fixed! The UWP UI has been totally rewritten and now even supports templating. This means that the objects are no longer managed manually.

mattleibow commented 6 years ago

Probably somewhere in here the world changed for a little SignaturePad control: d77cdf787175179212856074e71e7a5dcc050062

jyt1902 commented 5 years ago

Hello @mattleibow How to solved this issue? We faced still crash issue in our Signature pad demo application Platform : UWP(Universal Windows Platform) Language : C#