-
Notifications
You must be signed in to change notification settings - Fork 55
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
OutOfMemoryError #30
Comments
Any chance you have a large image you are trying to set as a View background? |
I set only color and background-color values with your library. |
I see. What device are you using, and how much memory does it have available. |
Nexus 5. If I disable your library my app works without crashes. |
The library has some memory consumption that is 'natural' to its work. As you can see from the stacktrace, there is a rendering of the background into a Bitmap, and that takes memory. The allocated Bitmap size in that case would be the size of the View you are trying to apply a background to. In case your device is that tight on memory, you should take that into account. Saying that does not mean that the library cannot be improved :) In cases where the CSS only defines a color, and not an image or a gradient color, it can be modified to set the color directly on the View (instead of using a backgroud bitmap). This will take some work, and you are welcome to look into the code in case you are interested. |
Thanks for the detailed answer! |
I found steps to reproduce: |
I get this error when I'm working in my app, not at the start app.
Nexus 5 (Android 5.1.1)
07-30 18:11:39.588 25364-25364/<my_app_package> E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: <my_app_package>, PID: 25364
java.lang.OutOfMemoryError: Failed to allocate a 712812 byte allocation with 278924 free bytes and 272KB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at android.graphics.Bitmap.nativeCreate(Native Method)
at android.graphics.Bitmap.createBitmap(Bitmap.java:812)
at android.graphics.Bitmap.createBitmap(Bitmap.java:789)
at android.graphics.Bitmap.createBitmap(Bitmap.java:756)
at com.pixate.freestyle.cg.shapes.PXShape.renderToImage(PXShape.java:288)
at com.pixate.freestyle.styling.stylers.PXStylerContext.getBackgroundImage(PXStylerContext.java:437)
at com.pixate.freestyle.util.PXDrawableUtil.createNewDrawable(PXDrawableUtil.java:417)
at com.pixate.freestyle.styling.adapters.PXViewStyleAdapter.updateWithNewStates(PXViewStyleAdapter.java:271)
at com.pixate.freestyle.styling.adapters.PXViewStyleAdapter.updateStyle(PXViewStyleAdapter.java:246)
at com.pixate.freestyle.styling.cache.PXStyleInfo.applyTo(PXStyleInfo.java:168)
at com.pixate.freestyle.styling.PXStyleUtils.updateStyle(PXStyleUtils.java:145)
at com.pixate.freestyle.styling.PXStyleUtils.updateStyles(PXStyleUtils.java:165)
at com.pixate.freestyle.styling.PXStyleUtils.updateStyles(PXStyleUtils.java:171)
at com.pixate.freestyle.styling.PXStyleUtils.updateStyles(PXStyleUtils.java:171)
at com.pixate.freestyle.PixateFreestyle.style(PixateFreestyle.java:268)
at com.pixate.freestyle.PXHierarchyListener$PXLayoutListener.onGlobalLayout(PXHierarchyListener.java:302)
at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:912)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1881)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1061)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5885)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
at android.view.Choreographer.doCallbacks(Choreographer.java:580)
at android.view.Choreographer.doFrame(Choreographer.java:550)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
The text was updated successfully, but these errors were encountered: