2

I am restarting the activity after updating some fields through api call, after 10-15 continuous updates it is giving an exception as below :

05-06 17:12:55.412: E/SurfaceFlinger(115): GraphicBufferAlloc::createGraphicBuffer(w=1232, h=800) failed (Out of memory), handle=0x0
05-06 17:12:55.412: E/BufferQueue(115): [com.ht.coremoney/com.ht.coremoney.cards.TransactionFullDetailActivity] dequeueBuffer: SurfaceComposer::createGraphicBuffer failed
05-06 17:12:55.420: E/libEGL(1350): eglMakeCurrent:534 error 3003 (EGL_BAD_ALLOC)
05-06 17:12:55.428: E/ViewRootImpl(1350): OutOfResourcesException initializing HW surface
05-06 17:12:55.428: E/ViewRootImpl(1350): android.view.Surface$OutOfResourcesException: eglMakeCurrent failed EGL_BAD_ALLOC
05-06 17:12:55.428: E/ViewRootImpl(1350):   at android.view.HardwareRenderer$GlRenderer.createEglSurface(HardwareRenderer.java:920)
05-06 17:12:55.428: E/ViewRootImpl(1350):   at android.view.HardwareRenderer$GlRenderer.initialize(HardwareRenderer.java:748)
05-06 17:12:55.428: E/ViewRootImpl(1350):   at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1621)
05-06 17:12:55.428: E/ViewRootImpl(1350):   at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
05-06 17:12:55.428: E/ViewRootImpl(1350):   at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4464)
05-06 17:12:55.428: E/ViewRootImpl(1350):   at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
05-06 17:12:55.428: E/ViewRootImpl(1350):   at android.view.Choreographer.doCallbacks(Choreographer.java:555)
05-06 17:12:55.428: E/ViewRootImpl(1350):   at android.view.Choreographer.doFrame(Choreographer.java:525)
05-06 17:12:55.428: E/ViewRootImpl(1350):   at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
05-06 17:12:55.428: E/ViewRootImpl(1350):   at android.os.Handler.handleCallback(Handler.java:615)
05-06 17:12:55.428: E/ViewRootImpl(1350):   at android.os.Handler.dispatchMessage(Handler.java:92)
05-06 17:12:55.428: E/ViewRootImpl(1350):   at android.os.Looper.loop(Looper.java:137)
05-06 17:12:55.428: E/ViewRootImpl(1350):   at android.app.ActivityThread.main(ActivityThread.java:4895)
05-06 17:12:55.428: E/ViewRootImpl(1350):   at java.lang.reflect.Method.invokeNative(Native Method)
05-06 17:12:55.428: E/ViewRootImpl(1350):   at java.lang.reflect.Method.invoke(Method.java:511)
05-06 17:12:55.428: E/ViewRootImpl(1350):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
05-06 17:12:55.428: E/ViewRootImpl(1350):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
05-06 17:12:55.428: E/ViewRootImpl(1350):   at dalvik.system.NativeStart.main(Native Method)
05-06 17:12:55.428: E/android.os.Debug(1350): !@Dumpstate > dumpstate -k -t -z -d -o /data/log/dumpstate_surfaceoom

Kindly suggest me the solution.

Araju
  • 511
  • 4
  • 17

2 Answers2

2

Let's analyse what this says:

GraphicBufferAlloc::createGraphicBuffer(w=1232, h=800) failed (Out of memory)

You seem to allocate a native buffer, 985600 pixels. If they use a 32-bit color format, that's 3.94 MB of memory. Taking into account that you do this 10 to 15 times, you allocate up to 59.14 MB of memory, far too much for most devices.

My guess is that you forgot to actually free these buffers, therefore wasting lots of memory. When using native code, your memory is only freed when your process is killed, not when the activity is restarted. Therefore, your code allocates a new buffer every time the activity is started. You should either free when the activity closes or reuse the already allocated buffer.

Community
  • 1
  • 1
tilpner
  • 4,401
  • 2
  • 19
  • 42
0

Let's understand Exception and Error in java.

In your situation you got an error by doing something wrong you can't handle or manage It like exception,

That's mean you need to analyze you memory management of your Application..

By the using the eclipse Memory Analyzer tools. It's plugged in already with Android ADT.

Here are link for using memory Analyzer.

http://www.vogella.com/tutorials/EclipseMemoryAnalyzer/article.html

http://android-developers.blogspot.in/2011/03/memory-analysis-for-android.html?m=1

I know it's not your direct solution but with the help of this tool you can analyze your all memory leakage and try to reuse your preallocated buffer ,

And android is also recommend that's do not use very complex layouting in a or heavy nested layouting in single layout, instead of all this you can break up all complex layout into sm fragments.

Hope this information help you.

Lavekush Agrawal
  • 5,724
  • 6
  • 46
  • 82