Reputation: 23
How can I enable large heap in my Xamarin.Forms application ?
Here is MainActivity.cs
Android code:
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
RoundedBoxViewRenderer.Init();
LoadApplication(new App());
}
}
See Exception Screenshot below:
Upvotes: 1
Views: 1068
Reputation: 11
My contribution, it worked for me:
[assembly: Application(LargeHeap = true)]
namespace Project.Droid
{
[Activity(.............)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
}
}
Upvotes: 0
Reputation: 74124
The Xamarin way of setting the Dalvik/Art large heap via the Appication
attribute:
using System;
using Android.App;
using Android.Runtime;
namespace LargeHeap
{
[Application(LargeHeap = true)]
public class XamarinApplication : Application
{
public XamarinApplication(IntPtr handle, JniHandleOwnership ownerShip) : base(handle, ownerShip)
{
}
}
}
If true, then the process should be created with a large Dalvik heap; otherwise, the process will be created with the default Dalvik heap.
Ref: https://developer.xamarin.com/api/property/Android.App.ApplicationAttribute.LargeHeap/
Upvotes: 1
Reputation: 149
Go to project Options > Android Build > General > Enable MultiDex & Options > Android Build > Advacnced > JavaHeapSize (Set 3G) , In manifest file you can add android:largeHeap="true" in Application Tag
<application android:largeHeap="true"/>
Upvotes: 1