Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Out of Memory Issue #29

Open
xavica opened this issue Apr 22, 2017 · 8 comments
Open

Out of Memory Issue #29

xavica opened this issue Apr 22, 2017 · 8 comments

Comments

@xavica
Copy link

xavica commented Apr 22, 2017

How to free up resources? and handle proper error handling?

Error: java.lang.OutOfMemoryError: Failed to allocate a 2073612 byte allocation with 1914240 free bytes and 1869KB until OOM
dalvik.system.VMRuntime.newNonMovableArray(Native Method)
android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
android.graphics.BitmapFactory.decodeStreamInternal(BitmapFactory.java:635)
android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:611)
android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:391)
com.tns.Runtime.callJSMethodNative(Native Method)
com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1197)
com.tns.Runtime.callJSMethodImpl(Runtime.java:1061)
com.tns.Runtime.callJSMethod(Runtime.java:1047)
com.tns.Runtime.callJSMethod(Runtime.java:1028)
com.tns.Runtime.callJSMethod(Runtime.java:1018)
com.tns.FragmentClass.onCreateView(android.app.Fragment.java)
android.app.Fragment.performCreateView(Fragment.java:2220)
android.app.FragmentManagerImpl.moveToState(FragmentManager.java:973)
android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1148)
android.app.BackStackRecord.run(BackStackRecord.java:793)
android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1535)
android.app.FragmentManagerImpl$1.run(FragmentManager.java:482)
android.os.Handler.handleCallback(Handler.java:739)
android.os.Handler.dispatchMessage(Handler.java:95)
android.os.Looper.loop(Looper.java:148)
android.app.ActivityThread.main(ActivityThread.java:5417)
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
File: "file:///data/data/com.test.android/files/app/tns_modules/tns-core-modules/image-source/image-source.js, line: 84, column: 54

StackTrace:
Frame: function:'ImageSource.loadFromFile', file:'file:///data/data/com.test.android/files/app/tns_modules/tns-core-modules/image-source/image-source.js', line: 84, column: 55
Frame: function:'fromFile', file:'file:///data/data/com.test.android/files/app/tns_modules/tns-core-modules/image-source/image-source-common.js', line: 21, column: 18
Frame: function:'getImage', file:'file:///data/data/com.test.android/files/app/tns_modules/nativescript-image-cache-media/imageCacheMedia.js', line: 50, column: 36
Frame: function:'imageCommon.ImageCacheMedia.imageUriProperty.metadata.onSetNativeValue', file:'file:///data/data/com.test..android/files/app/tns_modules/nativescript-image-cache-media/

@bathejasumeet
Copy link
Contributor

okay .. can you please tell me when you face this? I need to reproduce .

Thanks

@davecoffin
Copy link

@bathejasumeet I also had this problem. I had a GridView displaying 16-30 images (before scrolling down), and they were all 600x600 images. I kept getting the memory issue. I changed the gridview to display images that are 100x100, and that improved things greatly. But, the images dont look crisp anymore.

@hettiger
Copy link

This might be causing the issue:

In contrast, when using ImageSource or Base64 encoded string, the Bitmap is transferred to Javascript, so it will be released when Javascript object reclaims. Javascript garbage collection happens less frequently than Java garbage collection which might lead to Out Of Memory.

Source: https://docs.nativescript.org/angular/best-practices/images-optimisations

@elvismercado
Copy link

Maybe you could expose garbage collection and call it with gc() whenever it is needed.
I would not know how you should expose javascript garbage collection in ios though.

@Whip
Copy link

Whip commented Aug 3, 2018

@hettiger Is this what you're referring to? https://docs.nativescript.org/angular/performance-optimizations/images-optimisations

The optimizations here are all about the <Image> tag which we're not using with this plugin. I was getting out of memory error with 50 images (all same, 65KB each for testing) but even after installing the plugin I'm still getting the error. I thought fresco was supposed to take care of clearing memory and optimization stuff.

@hettiger
Copy link

hettiger commented Aug 3, 2018

@VeeK727 I just wanted to add some information that I've had found in this article and thought it might be related with the issue described here.

@webmeemba
Copy link

Out of Memory Issue - 6000 items

Hi, I need to be able to show in a radlistview 7000 elements with cached images in an optimal way. Currently the url of the image is 400x300 / imagen.jpg. But when you go displaying products in the view it becomes corrupted. Someone could help me?

Thanks!

@webmeemba
Copy link

any solutions ? help ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants