问题
In my barcode scanner application, using zbar lib for scanning barcode. It is thowing runtime exception as OutOfMemoryError.
Anybody please help to resolve this issue.
logcat:
2-16 13:06:01.635: W/linker(15501): libzbarjni.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
12-16 13:06:06.483: E/art(15501): Throwing OutOfMemoryError "Failed to allocate a 53654136 byte allocation with 16777216 free bytes and 47MB until OOM"
12-16 13:06:06.483: E/AndroidRuntime(15501): Error reporting crash
12-16 13:06:06.483: E/AndroidRuntime(15501): java.lang.OutOfMemoryError: Failed to allocate a 53654136 byte allocation with 16777216 free bytes and 47MB until OOM
12-16 13:06:06.483: E/AndroidRuntime(15501): at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:95)
12-16 13:06:06.483: E/AndroidRuntime(15501): at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:125)
12-16 13:06:06.483: E/AndroidRuntime(15501): at java.lang.StringBuffer.append(StringBuffer.java:278)
12-16 13:06:06.483: E/AndroidRuntime(15501): at java.io.StringWriter.write(StringWriter.java:123)
12-16 13:06:06.483: E/AndroidRuntime(15501): at com.android.internal.util.FastPrintWriter.flushLocked(FastPrintWriter.java:358)
12-16 13:06:06.483: E/AndroidRuntime(15501): at com.android.internal.util.FastPrintWriter.appendLocked(FastPrintWriter.java:303)
12-16 13:06:06.483: E/AndroidRuntime(15501): at com.android.internal.util.FastPrintWriter.write(FastPrintWriter.java:625)
12-16 13:06:06.483: E/AndroidRuntime(15501): at com.android.internal.util.FastPrintWriter.append(FastPrintWriter.java:658)
12-16 13:06:06.483: E/AndroidRuntime(15501): at java.io.PrintWriter.append(PrintWriter.java:691)
12-16 13:06:06.483: E/AndroidRuntime(15501): at java.io.PrintWriter.append(PrintWriter.java:31)
12-16 13:06:06.483: E/AndroidRuntime(15501): at java.lang.Throwable.printStackTrace(Throwable.java:324)
12-16 13:06:06.483: E/AndroidRuntime(15501): at java.lang.Throwable.printStackTrace(Throwable.java:300)
12-16 13:06:06.483: E/AndroidRuntime(15501): at android.util.Log.getStackTraceString(Log.java:335)
12-16 13:06:06.483: E/AndroidRuntime(15501): at com.android.internal.os.RuntimeInit.Clog_e(RuntimeInit.java:59)
12-16 13:06:06.483: E/AndroidRuntime(15501): at com.android.internal.os.RuntimeInit.access$200(RuntimeInit.java:43)
12-16 13:06:06.483: E/AndroidRuntime(15501): at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:85)
12-16 13:06:06.483: E/AndroidRuntime(15501): at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
12-16 13:06:06.483: E/AndroidRuntime(15501): at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
回答1:
I am getting this error on some devices because of memory issues. And I resolved it by importing the zbar whole lib code in workspace and using zbar lib app as lib from workspace instead of adding/keeping lib(.jar) in my own application.
来源:https://stackoverflow.com/questions/27500458/libzbarjni-so-has-text-relocations-this-is-wasting-memory-and-prevents-security