OutOfMemoryError: pthread_create

730 views
Skip to first unread message

itzno...@gmail.com

unread,
Jun 18, 2022, 2:15:23 PM6/18/22
to Google Mobile Ads SDK Developers
This issue has resurfaced in the latest 21.0.0 SDK version but has issues with the internal ExoPlayer it seems.
Previously reported here (a bit different though): https://groups.google.com/g/google-admob-ads-sdk/c/KHLd0TahsAc/m/GGvOt8aPAAAJ

Note: All data is according to Crashlytics

Affected Ad Type: Interstitial (AdActivity::class.java)
Affected Android versions: Android 9/10
Devices affected: Motorola [moto e(7) power,  moto g(6)]
Locally reproducible: No (please don't ask for a sample)
Crash Rate: Very Low

Below are the stacktraces:

#Stacktrace 1
Fatal Exception: java.lang.OutOfMemoryError: pthread_create (1040KB stack) failed: Try again
       at java.lang.Thread.nativeCreate(Thread.java)
       at java.lang.Thread.start(Thread.java:733)
       at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:975)
       at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1382)
       at java.util.concurrent.Executors$DelegatedExecutorService.execute(Executors.java:624)
       at com.google.android.gms.ads.exoplayer3.upstream.n.c(n.java)
       at com.google.android.gms.ads.exoplayer3.upstream.n.b(n.java:3)
       at com.google.android.gms.ads.exoplayer3.source.i.r(i.java:5)
       at com.google.android.gms.ads.exoplayer3.source.i.n(i.java)
       at com.google.android.gms.ads.exoplayer3.source.p.n(p.java)
       at com.google.android.gms.ads.exoplayer3.n.handleMessage(n.java:18)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:193)
       at android.os.HandlerThread.run(HandlerThread.java:65)
------------------------------------------------------------------------------------------------------------------------------------------
#Stacktrace 2
Fatal Exception: java.lang.OutOfMemoryError: pthread_create (1040KB stack) failed: Try again
       at java.lang.Thread.nativeCreate(Thread.java)
       at java.lang.Thread.start(Thread.java:883)
       at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:975)
       at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1382)
       at java.util.concurrent.Executors$DelegatedExecutorService.execute(Executors.java:630)
       at com.google.android.exoplayer2.upstream.Loader$LoadTask.execute(Loader.java:510)
       at com.google.android.exoplayer2.upstream.Loader$LoadTask.start(Loader.java:363)
       at com.google.android.exoplayer2.upstream.Loader.startLoading(Loader.java:257)
       at com.google.android.exoplayer2.source.ProgressiveMediaPeriod.startLoading(ProgressiveMediaPeriod.java:818)
       at com.google.android.exoplayer2.source.ProgressiveMediaPeriod.prepare(ProgressiveMediaPeriod.java:234)
       at com.google.android.exoplayer2.source.MaskingMediaPeriod.prepare(MaskingMediaPeriod.java:145)
       at com.google.android.exoplayer2.ExoPlayerImplInternal.maybeUpdateLoadingPeriod(ExoPlayerImplInternal.java:1997)
       at com.google.android.exoplayer2.ExoPlayerImplInternal.updatePeriods(ExoPlayerImplInternal.java:1977)
       at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:964)
       at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:499)
       at android.os.Handler.dispatchMessage(Handler.java:103)
       at android.os.Looper.loop(Looper.java:214)
       at android.os.HandlerThread.run(HandlerThread.java:67)

------------------------------------------------------------------------------------------------------------------------------------------
#Stacktrace 3
Fatal Exception: java.lang.OutOfMemoryError: pthread_create (1040KB stack) failed: Try again
       at java.lang.Thread.nativeCreate(Thread.java)
       at java.lang.Thread.start(Thread.java:883)
       at com.google.android.gms.ads.exoplayer3.video.e.b(e.java:4)
       at com.google.android.gms.ads.exoplayer3.video.h.J(h.java:13)
       at com.google.android.gms.ads.exoplayer3.mediacodec.c.N(c.java:12)
       at com.google.android.gms.ads.exoplayer3.mediacodec.c.G(c.java:4)
       at com.google.android.gms.ads.exoplayer3.video.h.G(h.java:1)
       at com.google.android.gms.ads.exoplayer3.mediacodec.c.z(c.java:3)
       at com.google.android.gms.ads.exoplayer3.n.handleMessage(n.java:42)
       at android.os.Handler.dispatchMessage(Handler.java:103)
       at android.os.Looper.loop(Looper.java:214)
       at android.os.HandlerThread.run(HandlerThread.java:67)

Mobile Ads SDK Forum Advisor

unread,
Jun 20, 2022, 10:33:00 AM6/20/22
to itzno...@gmail.com, google-adm...@googlegroups.com

Hi Itznotabug,

Thank you for reaching out to us.

Before we share this to the rest of the team, can you provide us some additional information on this privately? You can provide the following details via Reply privately to author option or send it directly to the link below.

  • App ID
  • Mediation adapter used(if any)

If the file(s) you are looking to share are less than 25mb in total you can attach them to this case on your next reply. If you are having trouble attaching your file to this case or if your file(s) are larger than 25mb, you can share your files with me by performing the following steps:

1. Navigate to https://docs.google.com/forms/d/e/1FAIpQLSfkAiXMeYP-fw1W3Z-tT9uwmATEKO5X6S-th0gR2ezdKaaqfg/viewform?usp=pp_url&entry.400550049=Mobile+Ads+SDK&entry.460850823=5004Q00002bxpKwQAI&entry.80707362=00111436
2. Fill out all fields, and attach your file(s).
3. Please reply back on this thread when you have uploaded your file(s). Please do not share this link.

Regards,

Google Logo
Princess Pamela
Mobile Ads SDK Team
 

 



ref:_00D1U1174p._5004Q2bxpKw:ref
Message has been deleted
Message has been deleted

Mobile Ads SDK Forum Advisor

unread,
Jul 12, 2022, 4:32:34 AM7/12/22
to itzno...@gmail.com, google-adm...@googlegroups.com

Hi Darshan,

Thank you for this additional stack trace. I've already provided this to the rest of the team. We will update you once we have more information from them.

itzno...@gmail.com

unread,
Sep 19, 2022, 3:16:28 AM9/19/22
to Google Mobile Ads SDK Developers
This has resurfaced again on the latest version of the Ads sdk.
Stacktrace: 
Fatal Exception: java.lang.OutOfMemoryError: pthread_create (1040KB stack) failed: Try again
       at java.lang.Thread.nativeCreate(Thread.java)
       at java.lang.Thread.start(Thread.java:883)
       at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:975)
       at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1382)
       at java.util.concurrent.Executors$DelegatedExecutorService.execute(Executors.java:630)
       at com.google.android.gms.ads.exoplayer3.upstream.n.c(n.java)
       at com.google.android.gms.ads.exoplayer3.upstream.n.b(n.java:3)
       at com.google.android.gms.ads.exoplayer3.source.i.r(i.java:5)
       at com.google.android.gms.ads.exoplayer3.source.i.n(i.java)
       at com.google.android.gms.ads.exoplayer3.source.p.n(p.java)
       at com.google.android.gms.ads.exoplayer3.n.handleMessage(n.java:18)
       at android.os.Handler.dispatchMessage(Handler.java:103)
       at android.os.Looper.loop(Looper.java:214)
       at android.os.HandlerThread.run(HandlerThread.java:67)

Not Reproducible locally.

Mobile Ads SDK Forum Advisor

unread,
Sep 19, 2022, 12:40:37 PM9/19/22
to itzno...@gmail.com, google-adm...@googlegroups.com

Hi Darshan,

Thank you for providing us the additional Stacktrace from the latest version of the Ads SDK. I’ve forwarded this details to the rest of the team. We will reach out to you as soon as possible. 

Regards,

Google Logo
Yasar
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q2bxpKw:ref

Mobile Ads SDK Forum Advisor

unread,
Mar 17, 2023, 4:12:24 PM3/17/23
to itzno...@gmail.com, google-adm...@googlegroups.com

Hi Darshan,

I hope you're doing well.

I just want to circle back with regard to your concern for OutOfMemoryError in your app. Our team mentioned that the error could be cause by many factors, and they mentioned that feel free to reach back to us if you can give us more insight into your stack trace.

Regards,

Google Logo Mobile Ads SDK Team


ref:_00D1U1174p._5004Q2bxpKw:ref

mastef ‎

unread,
Nov 10, 2023, 9:21:39 AM11/10/23
to Google Mobile Ads SDK Developers
Maybe related to https://groups.google.com/g/google-admob-ads-sdk/c/pujkgoldM2s/m/6kPzzIx7BAAJ

The recurring issue seems to be that admob library / AdWorkers create too many threads by accident which lead to an out of memory crash?

If the underlying app is also multi threaded possibly the crashes appear even sooner? Just an idea.

In the latest admob version this is one of our most common crashes

Bogdan Florian Nica

unread,
Jan 12, 2024, 7:56:10 AM1/12/24
to Google Mobile Ads SDK Developers
I'm also seeing this crash since I've added the Google's User Messaging Platform SDK.
Debugging an empty app (with only UMP) shows that the SDK is creating a lot of threads (increased from 21 to ~43).
These threads are not destroyed when then Consent Form is being dismissed causing the app to crash a bit later when ads are being initialized (most likely because ads also create a number of threads)..

The OutOfMemory message is not because the app is low on memory, it's just because the Android OS has a limit on how many threads it can create in a process/game.

Bogdan Florian Nica

unread,
Jan 12, 2024, 8:50:08 AM1/12/24
to Google Mobile Ads SDK Developers
We've also tested removing the UMP SDK in a version and we can see the crash is gone.

Mobile Ads SDK Forum Advisor

unread,
Jan 12, 2024, 9:22:10 AM1/12/24
to bog...@sybogames.com, google-adm...@googlegroups.com

Hi,

Thank you for contacting the Mobile Ads SDK Support team.

I will check with our team regarding your query and one of my team members will reach out to you once we have an update on this. Meanwhile, your patience is highly appreciated.

This message is in relation to case "ref:!00D1U01174p.!5004Q02bxpKw:ref"

Thanks,

 
Google Logo Mobile Ads SDK Team

 

Mobile Ads SDK Forum Advisor

unread,
Jan 12, 2024, 5:05:43 PM1/12/24
to bog...@sybogames.com, google-adm...@googlegroups.com
Hello,

I am unable to reproduce the issue using our BannerExample on a Pixel 4 API 32. Can you share the device information that are you testing with? Are you able to consistently reproduce this crash? Can you share the stack trace of the crash?

Thanks,
Justin

ref:!00D1U01174p.!5004Q02bxpKw:ref

Bogdan Florian Nica

unread,
Jan 19, 2024, 7:25:47 AM1/19/24
to Google Mobile Ads SDK Developers
Hello,
We can not reproduce this inHouse, only see this crash on Crashlytics and Google Play Console. I've attached a stacktrace example, crashed Thread AdWorker
This occurs on old devices (attached screenshot with device example).
devices example.png
_crash_stacktrace.txt

Mobile Ads SDK Forum Advisor

unread,
Jan 19, 2024, 7:05:04 PM1/19/24
to bog...@sybogames.com, google-adm...@googlegroups.com
Hello,

Looking at the stack trace there doesn't appear to be anything that would indicate the UMP SDK. Perhaps adding the UMP SDK revealed the bug that perhaps on app start there is an overload of work being done. We recommend optimizing initialization and not initializing the Google Mobile Ads SDK until consent has been gathered/obtained. And if possible, reduce the number of tasks running on the main thread. This may help lighten the load for older devices. 

Bogdan Florian Nica

unread,
Jan 20, 2024, 3:43:03 AM1/20/24
to Google Mobile Ads SDK Developers
Hello,
- We are not doing anything(not initializing any 3rdParty or ads) until after the UMP has finished. The issue is that UMP does not clear threads after the popup has closed (from the test we've done on an empty project. As mentioned, after removal of the SDK crash rate went down, but since it's something required we need to have it.
- We are using both initialization flags for admob (Optimize_initialization and optimize_ad_loading are set to true in manifest.).  We were actually thinking of testing disabling those since we think that those flags increase the number of threads AdMob uses (in order to do work on background). 

Mobile Ads SDK Forum Advisor

unread,
Jan 22, 2024, 10:53:48 AM1/22/24
to bog...@sybogames.com, google-adm...@googlegroups.com
Hello,

If you can provide a stack trace with 
ump

explicitly in the stack trace that would be most helpful for us to take a closer look. We haven't had other publishers flag this (crash on launch from the UMP SDK). Given that the crash is not reproducible and that is also occurs mostly on older devices, the existing stack trace as is is rather infeasible for us to take any actionable next steps related to the UMP SDK. Feel free to experiment with your implementation and startup logic to lighten the load for those older devices.
Reply all
Reply to author
Forward
0 new messages