We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Memory Leak on setting view in OnMonthCellLoadedEvent

Using sfSchedule v17.1.0.47 as you can see in the attached sample code, there's a major memory leak depending on the type of view you create on a cell in the OnMonthCellLoadedEvent callback.

Using a simple StackLayout as in your sample browser, I couldn't detect a leak.

However, when I changed to use the code from your documentation, which inserts a Button, I get a leak on both Android and iOS.

To replicate the leak, build and run the attached sample and swipe back and forwards through a few months.

Note that I first identified this using SkiaSharp in the cells and built the attached sample to verify that the leak was not associated with that library at all.

Attachment: MonthCellCustModernLeakOnViewSetting_c473deb0.zip

17 Replies

SP Subburaj Pandian Veluchamy Syncfusion Team May 16, 2019 01:14 PM UTC

Hi Andy, 
 
Thank you for contacting Syncfusion support. 
  
We have analyzed the reported issue "Memory leak in schedule Android and iOS" and it works fine from our end. We need ensure memory leak by navigate to any other page from schedule, and on this scenario there is no memory leak on schedule. We have tested the shared sample and it doesn't have any navigation to schedule on this scenario new view created for first three views then we have reused the already available view hence the memory will increase for first three swipes and it becomes stable. 
  
We have attached the sample with navigation page and the screenshot of tested results. 
  
 
Please check the sample and revert us if you have any concern. 
 
Regards,
Subburaj Pandian V   
 



AD Andy Dent May 16, 2019 02:52 PM UTC

I easily replicated the crash.

I downloaded your app, built and ran it on my Samsung SM-T710 device. (I noticed your archive built the same name app as my submission so uninstalled my earlier build first on the tablet.)

I swiped right multiple times from May 2019 up to October 2019 then swiped left until it crashed at December 2018. Application output attached, crash summary copied inside Visual Studio Mac below.

Java.Lang.OutOfMemoryError: OutOfMemoryError thrown while trying to throw OutOfMemoryError; no stack trace available
  at Java.Interop.JniEnvironment+StaticMethods.CallStaticObjectMethod (Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069] in <09821b4f44794452b7d6c054ac9447f5>:0
  at Java.Interop.JniPeerMembers+JniStaticMethods.InvokeObjectMethod (System.String encodedMember, Java.Interop.JniArgumentValue* parameters) [0x00018] in <09821b4f44794452b7d6c054ac9447f5>:0
  at Android.Graphics.Bitmap.CreateBitmap (System.Int32 width, System.Int32 height, Android.Graphics.Bitmap+Config config) [0x0005a] in <788a34f7a7b84486905dfde786529d42>:0
  at Xamarin.Forms.Platform.Android.BorderDrawable.CreateBitmap (System.Boolean pressed, System.Int32 width, System.Int32 height) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\Renderers\BorderDrawable.cs:174
  at Xamarin.Forms.Platform.Android.BorderDrawable.Draw (Android.Graphics.Canvas canvas) [0x000c9] in D:\a\1\s\Xamarin.Forms.Platform.Android\Renderers\BorderDrawable.cs:90
  at Android.Graphics.Drawables.Drawable.n_Draw_Landroid_graphics_Canvas_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_canvas) [0x00011] in <788a34f7a7b84486905dfde786529d42>:0
  at at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.61(intptr,intptr,intptr)
  at java.lang.OutOfMemoryError: OutOfMemoryError thrown while trying to throw OutOfMemoryError; no stack trace available


Attachment: ApplicationOutput.txt_5f065bb1.zip


AD Andy Dent May 16, 2019 03:34 PM UTC

A further thought, if you're having trouble replicating, swipe a little faster.

I just did further testing on a 32bit device, as I'd only tested on the 64bit Samsung, this time on my old Motorola XT1033. It gets the same crash. I also tested only swiping in one direction in case the bug required swiping forward then back.

I replicated it swiping steadily, each time about as soon as the screen showed a new month. I got up to June 2021 before it crashed.


AD Andy Dent replied to Subburaj Pandian Veluchamy May 17, 2019 04:26 AM UTC

Hi Andy, 
 
Thank you for contacting Syncfusion support. 
  
We have analyzed the reported issue "Memory leak in schedule Android and iOS" and it works fine from our end. We need ensure memory leak by navigate to any other page from schedule, and on this scenario there is no memory leak on schedule. We have tested the shared sample and it doesn't have any navigation to schedule on this scenario new view created for first three views then we have reused the already available view hence the memory will increase for first three swipes and it becomes stable. 
  
We have attached the sample with navigation page and the screenshot of tested results. 
  
 
Please check the sample and revert us if you have any concern. 
 
Regards,
Subburaj Pandian V   
 


We need ensure memory leak by navigate to any other page from schedule, and on this scenario there is no memory leak on schedule

I don't understand what you mean by needing navigation.

The sample I provided demonstrates the leak just by swiping through the months. There's no page navigation required. 

As I have already commented, I also replicated the leak with your sample. I am concerned you are evaluating this as something to do with navigation.

One of the main features of the rewrite I'm doing with Syncfusion is to allow users to swipe from one month to the next - it is the main reason why many people stopped using the previous app. 

Just to be clear, you have to swipe through many months to get a crash, at least 18. That seems consistent using your sample with the Button and my SkiaSharp views.

Note the amount of drawing inside SkiaSharp has no effect - I run out of memory at about the same time with an empty SKCanvasView or with a mix of shapes and text drawn in the cells. It is just a leak of the view. 




SP Subburaj Pandian Veluchamy Syncfusion Team May 17, 2019 12:28 PM UTC

Hi Andy, 
  
Thank you for the update. 
  
We have analyzed and we unable to replicate the reported issue “Out of Memory exception occurs while swiping schedule with button as custom view”. Based on schedule implementation, we have converted the Xamrin.Forms view to native view and there is a Framework issue in view conversion from forms view to native view, which makes the conversion slow and affects the schedule swiping performance while using custom view. We have logged an issue report for the same with Xamarin. 
  
Kindly refer the following link for the same, 
 
 
We suspect that exception may raided because of this performance issue, while swiping fast will sent the notification to schedule and tries to create new views without clearing the already created views which cause this exception. Once we get the solution from Xamarin team, we will change our implementation which will resolve this exception. We appreciate your patience until then. 
  
Kindly revert us if you have any concern. 
 
Regards,
Subburaj Pandian V    



AD Andy Dent May 17, 2019 01:37 PM UTC

It is an attractive theory that swiping fast is the cause.

So I just tested my app and the sample. I swiped and waited for a count of five seconds before the next swipe.

My app ran out of memory at December 2020.

Your sample ran out of memory at June 2020.

I then tested your sample again waiting a full 30 seconds (or more) on each screen. It ran out of memory at exactly the same date.

I don't think this is a timing issue.

I am very concerned, however, that you are unable to replicate the problem. Has someone actually sat on a device and swiped through screens from May 2019 to December 2020 and been able to keep going? What is different about your setup and mine?


AD Andy Dent May 17, 2019 02:23 PM UTC

As I have been working on this app for some time and don't remember these problems from earlier testing, I decided to test older versions of Syncfusion.

I went back to 15.4.0.20 because I reviewed release notes and spotted this entry

  • #195593 - Now, Custom view and cell style applied in MonthCellLoaded event will not get cleared after a Swipe Xamarin.Forms(Android).
That version crashes in the same manner, indicating it's not a recent change which causes the vulnerability.

In our app, you can navigate to the next month using a button as well as a swipe, so I tested going through the months using just the buttons - same crash at the same point.
That confirms it's not the act of swiping but just changing months which is the problem, in this case calling Schedule.Forward(). 


SP Subburaj Pandian Veluchamy Syncfusion Team May 20, 2019 12:06 PM UTC

Hi Andy, 
  
Thank you for the update. 
  
We can reproduce the reported issue “OutofMemory exception occurs while swiping schedule with button as custom view” only on Samsung SM-T710 device. Currently, we are analyzing on this based on our source. We will update you the further details in two business days (May 22, 2019). We appreciate your patience until then. 
 
Regards,
Subburaj Pandian V    



AD Andy Dent May 21, 2019 05:04 AM UTC

I have verified the crash also occurs on my ZTE Blade V7 Plus running Android 6.0 and Motorola Moto G XT1033 running Android 5.1.

Logs attached. Note that swiping speed and delays between speeds made no apparent difference. I did a test with the Blade where I swiped as fast as new months appeared and tested with both with at least a 5 second delay after new months drew but the Blade crashed at the same point. Interestingly, it made it a lot farther than the Samsung before crashing, taking about 20 refreshes before a crash.

Attachment: More_leak_logs_5a92d533.zip


SP Subburaj Pandian Veluchamy Syncfusion Team May 21, 2019 12:53 PM UTC

Hi Andy,  
   
Thank you for the update.  
   
Currently we are analyzing on this issue with our Schedule source and sample level. We need some more time to work on this probably one week. We will validate and update you the further details by May 28, 2019. We appreciate your patience until then.  
 
Regards,
Subburaj Pandian V 



SP Subburaj Pandian Veluchamy Syncfusion Team May 28, 2019 02:22 PM UTC

  
Thank you for your patience. 
  
We have analyzed reported issue “OutofMemory exception occurs while swiping schedule with button as custom view”. In our Schedule we have used 126 views on custom month cell loaded and removed all those views before moving to next view. While swiping, OutOfMemery exception throws due to bitmap images. 
  
Xamarin forms convert forms view to native in image form, while moving to next month from current view this conversion requires more memory space, which results in OutOfMemory exception, this can be resolved by increasing heap memory and this can be achieved in sample level by using android:largeHeap="true" in android AndroidManifest.xml file. 
  
Code Snippet 
<manifest xmlns:android="http://schemas.android.com/apk/res/android"android:versionCode="1" android:versionName="1.0"package="com.companyname.monthcellcustmodern"> 
              <uses-sdk android:minSdkVersion="21"android:targetSdkVersion="27" /> 
              <application android:label="MonthCellCustModern.Android"android:largeHeap="true></application> 
</manifest> 
  
Further, we have followed up for the same with Xamarin team, we will improve this once we get solution from them. Currently, we have modified your sample to resolve OutofMemory exception. 
  
Sample link: Schedule 
  
We hope this helps. Kindly revert us if you have any concern. 
 
Regards,
Subburaj Pandian V 



AD Andy Dent May 29, 2019 06:35 AM UTC

Thanks for your efforts but the crash still occurs.

On the Samsung SM-T710 your new sample crashes swiping through to Dec 2022.

This implies the problem is indeed a leak of the images, which is what I expected from the patterns in my previous testing. Using the large heap helps defer but doesn't fix the problem to a degree where the app is usable for release.


SP Subburaj Pandian Veluchamy Syncfusion Team May 30, 2019 10:20 AM UTC

Hi Andy, 
  
Thank you for the update. 
 
We have checked the mentioned crashing issue “OutofMemory exception throws while swiping schedule through December 2022” with the provided sample in Samsung SM-T710 tablet and it works fine as expected from our end.  
 
We have also attached the video for the same, 
  
 
We would like to have web meeting to investigate on this issue. So, we have created a new incident under your account. Please log on to our support website to check for further updates.   
  
 
Regards,
Subburaj Pandian V  



AD Andy Dent July 5, 2019 06:27 AM UTC

Note that this issue is fixed in SyncFusion 17.1.0.53 for Android, but still has iOS issues to a lesser extent.


SP Subburaj Pandian Veluchamy Syncfusion Team July 5, 2019 12:55 PM UTC

Hi Andy, 
  
Thank you for the update. 
  
We have checked the reported issue “OutofMemory exception while swiping schedule more than 300 times in iOS” and unfortunately, we are unable to reproduce the crash in the provided sample. We are checking this in all possible scenarios and try to replicate at our end. We will update you further details on or before July 10, 2019. We appreciate your patience until then. 
 
Regards,
Subburaj Pandian V 



AD Andy Dent July 6, 2019 02:43 AM UTC

I started a new thread for the iOS issue with an attached sample.
That includes the automated advance sample which helped identify the Android leak.

As noted over in that thread, I have an Instruments recording showing the steady leak but need a way to upload 300MB of zip file for you.


SP Subburaj Pandian Veluchamy Syncfusion Team July 6, 2019 12:09 PM UTC

Hi Andy, 
 
Thank you for the update. 
 
We will check and update the details in the created forum (#155723). Please follow-up with the forum (#145723) for further updates. 
 
For Uploading larger file: Please share the files through google drive to this account fileupload.sync@gmail.com and share that link to us. 
 
Regards,
Subburaj Pandian V 


Loader.
Live Chat Icon For mobile
Up arrow icon