in Visual Studio Xamarin out of memory error inside the binding library

using visual studio xamarin after binding an image-processing library, and imported the .Dll file as reference to my App project. when i pass an image to the library the App crash with this error

Java.Lang.OutOfMemoryError: Failed to allocate a 91411212 byte allocation with 2810016 free bytes and 2MB until OOM

it occurs inside the library only when i pass a large image files >2MB.
i already increased the java max heap size for the project to max (1G)

Answers

  • AyadKaraAyadKara USMember

    i temporarily managed that error by scaling the Source image to smaller one

  • BatzeeBatzee LKMember ✭✭
    edited May 2016

    You Can increase the Memory allotted to your application by adding android:largeHeap="true" in manifest.

    Note : Increasing heap for your application doesn't considered to be a ideal solution.

    Here's the extract from google that explains it,

    However, the ability to request a large heap is intended only for a small set of apps that can justify the need to consume more RAM (such as a large photo editing app). Never request a large heap simply because you've run out of memory and you need a quick fix—you should use it only when you know exactly where all your memory is being allocated and why it must be retained. Yet, even when you're confident your app can justify the large heap, you should avoid requesting it to whatever extent possible. Using the extra memory will increasingly be to the detriment of the overall user experience because garbage collection will take longer and system performance may be slower when task switching or performing other common operations.

    here's the complete link of the documentation

Sign In or Register to comment.