0

My app is showing this error on logCat:

java.lang.OutOfMemoryError: 

  at java.lang.AbstractStringBuilder.enlargeBuffer (AbstractStringBuilder.java:95)

  at java.lang.AbstractStringBuilder.append0 (AbstractStringBuilder.java:146)

  at java.lang.StringBuilder.append (StringBuilder.java:216)

  at org.chromium.content_public.browser.LoadUrlParams.buildDataUri (LoadUrlParams.java:27)

  at org.chromium.content_public.browser.LoadUrlParams.createLoadDataParamsWithBaseUrl (LoadUrlParams.java:35)

  at org.chromium.android_webview.AwContents.loadDataWithBaseURL (AwContents.java:431)

  at com.android.webview.chromium.WebViewChromium.loadDataWithBaseURL (WebViewChromium.java:188)

  at android.webkit.WebView.loadDataWithBaseURL (WebView.java:960)

  at com.google.android.gms.ads.internal.webview.p.loadDataWithBaseURL (:com.google.android.gms.DynamiteModulesA:132)

  at com.google.android.gms.ads.internal.webview.o.loadDataWithBaseURL (:com.google.android.gms.DynamiteModulesA:103)

  at com.google.android.gms.ads.internal.renderer.i.a (:com.google.android.gms.DynamiteModulesA:8)

  at com.google.android.gms.ads.internal.renderer.a.c (:com.google.android.gms.DynamiteModulesA:35)

  at com.google.android.gms.ads.internal.renderer.g.a (:com.google.android.gms.DynamiteModulesA:11)

  at com.google.android.gms.ads.internal.k.run (:com.google.android.gms.DynamiteModulesA:28)

  at android.os.Handler.handleCallback (Handler.java:739)

  at android.os.Handler.dispatchMessage (Handler.java:95)

  at android.os.Looper.loop (Looper.java:145)

  at android.app.ActivityThread.main (ActivityThread.java:6939)

  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:1404)

  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1199)

and I have no idea where is coming from, 'cause this error type normally came from images, but I know that don't. And it says something about stringBuilder and I really use a StringBuilder to create a string that will be stored on sharedPreferences, this string is a kind of array, then I use a lot the .append() to put each position and a separator commom. Like this

sb.append("5").append("/"); ...

then the final result is some like this:

5/3/7/27/10

Anyone can tell me whats happen?

Thx

Oussema Aroua
  • 5,225
  • 1
  • 24
  • 44
Cristina
  • 387
  • 1
  • 18
  • we need some code to work with – MohammedAlSafwan Jul 30 '17 at 15:06
  • Keep going down the stack trace until you see something from your code. (Everything you posted is from Android, Google, Java, etc.) That line of code will be where the problem starts. – Gary99 Jul 30 '17 at 17:24
  • @Gary99 The problem is I don't have more stack trace to going down... I caught this error on Google Play report and there says only this. But how I work with stringBuilder to create a string array and store it on sharedPreferences I assumed that this can be the error... But I don't have any sure. My doubt is the stringBuilder can cause this error type? I used to see this error just on images... – Cristina Aug 02 '17 at 13:08
  • I see. The error happens after `AbstractStringBuilder.enlargeBuffer`. I couldn't find docs for this but I know in some other cases with dynamically allocated memory, the size is doubled when more is needed. You may only be needing a little more than half of the available memory but still get this error. Have you looked up the specs for the device (or is this happening on multiple devices)? Maybe it only happens on low end devices with small memory. It's happening when you're building a uri/url. Any chance the length of this is really going crazy? – Gary99 Aug 02 '17 at 13:38
  • @Gary99 I'm new on this, and my native language is not english, so this make Google Play console be a little confusing to me. I don't think so length is going crazy, 'cause is a simple string array, it can have from 0 to 30 itens, no more (some like this: 3/5/4/7... for example), and each time that I write this array on sharedPreferences the old one is overwritten, by (see continuation below) – Cristina Aug 04 '17 at 14:50
  • `editor.putString(key, str); editor.apply();` and I was looking for something on GP reports and find out that this is happen in a old version of my app, but strange thing is when I click to see details is showing 0 fails on last 7 days, however on painel the graphic show 1 fail yesterday But the number of users afected inform just 1 on Samsung Galaxy Tab A 7.0 (gtexswifi), 1536MB RAM, Android 5.1... – Cristina Aug 04 '17 at 14:53
  • I'm don't know why Google Play shows different info about the crash. Have you seen [this](https://stackoverflow.com/questions/19537550/android-out-of-memory-error-stringbuilder?rq=1)? For the StringBuilder, are you starting with a new one each time? `StringBuilder myBuilder = new StringBuilder();` or do you have a global variable you re-use each time? I don't know what else to say. It would help if you could show some code. – Gary99 Aug 04 '17 at 15:06
  • @Gary99 I create a new stringBuilder each time that I will use it. Actually I created a method that create my arrays and stored it on sharedPreferences. I call this method always that is need, inside this method I create a stringBuilder. This is wrong? Is better to create a global one? I was repairing also on Aplication Manager -> App Info that my app has 50M of size but the total reach 70M 80M easily (size + data), this is strange 'cause except this sharedPreferences file a do not store any data. but I use Appodeal, but I don't think so that here is the problem. – Cristina Aug 05 '17 at 16:41
  • A new StringBuilder each time is better. I thought if you were using a global , that each new string may be building on all the older ones and causing your problem. Sorry, I'm out of ideas. – Gary99 Aug 05 '17 at 16:50
  • @Gary99 Really thanks for your help and your attention. :) – Cristina Aug 06 '17 at 14:16
  • I had similarly crash, 'outofmemory' with android.webkit.WebView.loadDataWithBaseURL(WebView.java:924) crash will occur by waiting around 4-5 minutes in page which already install ads then suddenly terminate. Any update? – Nanda Z Jun 12 '19 at 03:06

1 Answers1

0

The bug originates from google Admob.

specifically

com.google.android.gms.ads.internal.webview.p.loadDataWithBaseURL(...)
...
com.google.android.gms.ads.internal.k.run(...)

I assume that the issue is that it generates erroneously a very long string of url (to load an ad as a webview) in some devices sometimes and crash the app

Although admob says that the fault resides in the user implementation and not the SDK https://groups.google.com/forum/#!topic/google-admob-ads-sdk/xtnAcmnPYFI

Angel Koh
  • 12,479
  • 7
  • 64
  • 91