java.lang.OutOfMemoryError: pthread_create (1040KB stack) failed: Try again

4,334 views
Skip to first unread message

赵楠

unread,
Jun 13, 2019, 11:41:39 PM6/13/19
to Google Mobile Ads SDK Developers
full crash logs:
  • java.lang.OutOfMemoryError: pthread_create (1040KB stack) failed: Try again
  •     at java.lang.Thread.nativeCreate(Native Method)
  •     at java.lang.Thread.start(Thread.java:733)
  •     at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:970)
  •     at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1388)
  •     at com.google.android.gms.ads.internal.util.future.ac.execute(Unknown Source:2)
  •     at com.google.android.gms.ads.nonagon.ad.activeview.b.a(:com.google.android.gms.policy_ads_fdr_dynamite@20290003@20290003.249178941.249178941:5)
  •     at com.google.android.gms.ads.internal.webview.j.a(:com.google.android.gms.policy_ads_fdr_dynamite@20290003@20290003.249178941.249178941:30)
  •     at com.google.android.gms.ads.internal.webview.ad.a(Unknown Source:4)
  •     at com.google.android.gms.ads.internal.webview.ae.run(Unknown Source:2)
  •     at android.os.Handler.handleCallback(Handler.java:794)
  •     at android.os.Handler.dispatchMessage(Handler.java:99)
  •     at aam.a(Unknown Source:0)
  •     at com.google.android.gms.ads.internal.util.e.a(:com.google.android.gms.policy_ads_fdr_dynamite@20290003@20290003.249178941.249178941:1)
  •     at aam.dispatchMessage(Unknown Source:0)
  •     at android.os.Looper.loop(Looper.java:176)
  •     at android.app.ActivityThread.main(ActivityThread.java:6662)
  •     at java.lang.reflect.Method.invoke(Native Method)
  •     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
  •     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
we use firebase-ads 17.2.1,it start from June 5th ,never saw it before

Mobile Ads SDK Forum Advisor Prod

unread,
Jun 14, 2019, 3:38:45 AM6/14/19
to zhn31...@gmail.com, google-adm...@googlegroups.com
Hi there,

Thank you for reporting this.

Is the issue locally reproducible on your end? If so, could you please provide us a project file (or at least a test project) where the issue is reproducible? 
Please use "Reply Privately to Author" option to share the details privately.

Regards,
Teejay Pimentel
Mobile Ads SDK Team

ref:_00D1U1174p._5001UBnHh5:ref

Туканов Артем

unread,
Jun 17, 2019, 3:04:23 AM6/17/19
to Google Mobile Ads SDK Developers
Hi! We have same error. If you will find solution, please notify us. Thank you in advance.

Steven Haggerty

unread,
Jun 20, 2019, 10:12:15 AM6/20/19
to google-adm...@googlegroups.com

Hi there,

We also have this (see below). This started on the 5th June as is getting increasingly severe. It is un-reproducable for me.
Given the callstack is looks like too many threads are being created/not cleaned up by the AdMob SDK.


Clipboard01.gif



Can we bump the priority of this one up please?

Many thanks

Steve.


java.lang.OutOfMemoryError:
at java.lang.Thread.nativeCreate (Native Method)
at java.lang.Thread.start (Thread.java:730)
at java.util.concurrent.ThreadPoolExecutor.addWorker (ThreadPoolExecutor.java:941)
at java.util.concurrent.ThreadPoolExecutor.execute (ThreadPoolExecutor.java:1359)
at com.google.android.gms.ads.internal.util.future.ac.execute (com.google.android.gms.policy_ads_fdr_dynamite@2029...@20290003.249178941.249178941)
at com.google.android.gms.ads.nonagon.ad.activeview.b.a (com.google.android.gms.policy_ads_fdr_dynamite@2029...@20290003.249178941.249178941:5)
at com.google.android.gms.ads.internal.webview.j.a (com.google.android.gms.policy_ads_fdr_dynamite@2029...@20290003.249178941.249178941:30)
at com.google.android.gms.ads.internal.webview.ad.a (Unknown Source)
at com.google.android.gms.ads.internal.webview.ae.run (Unknown Source)
at android.os.Handler.handleCallback (Handler.java:751)
at android.os.Handler.dispatchMessage (Handler.java:95)
at aam.a (com.google.android.gms.policy_ads_fdr_dynamite@2029...@20290003.249178941.249178941)
at com.google.android.gms.ads.internal.util.e.a (com.google.android.gms.policy_ads_fdr_dynamite@2029...@20290003.249178941.249178941:1)
at aam.dispatchMessage (com.google.android.gms.policy_ads_fdr_dynamite@2029...@20290003.249178941.249178941)
at android.os.Looper.loop (Looper.java:154)
at android.app.ActivityThread.main (ActivityThread.java:6312)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:872)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:762)


Heberth Vargas

unread,
Jul 3, 2019, 6:26:56 AM7/3/19
to Google Mobile Ads SDK Developers
i have the same problem .....

android user

unread,
Jan 27, 2020, 1:33:14 AM1/27/20
to Google Mobile Ads SDK Developers
Yes I am also having the same problem... Too many threads are getting created for Ads. Its slow down my overall app performance.
Please help

Mobile Ads SDK Forum Advisor Prod

unread,
Jan 27, 2020, 5:40:16 AM1/27/20
to dev0...@gmail.com, google-adm...@googlegroups.com
Hi all,

Could you kindly confirm if this issue is still occurring on the latest version of the AdMob SDK? If so, you may send the details below (via Reply privately to author) option so that I can bring this up to the rest of the team:
  • Android version
  • Affected devices
  • Crash rate
  • Copy of the logs
  • Copy of your sample project (replicating the issue), as well as steps to reproduce
  • Other relevant details (such as Mediation setup if any)
Regards,
Teejay Pimentel
Mobile Ads SDK Team

ref:_00D1U1174p._5001USx00v:ref

junaid Umar

unread,
May 14, 2020, 2:00:16 PM5/14/20
to Google Mobile Ads SDK Developers
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:731)
       at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:941)
       at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1359)
       at com.google.android.gms.internal.ads.zzbag.execute(com.google.android.gms:play-services-ads@@19.1.0:4)
       at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:111)
       at com.google.android.gms.internal.ads.zzdpz.zzd(com.google.android.gms:play-services-ads@@19.1.0:5)
       at com.google.android.gms.internal.ads.zzczr.zzaqa(com.google.android.gms:play-services-ads@@19.1.0:6)
       at com.google.android.gms.internal.ads.zzdaj.zzt(com.google.android.gms:play-services-ads@@19.1.0:7)
       at com.google.android.gms.internal.ads.zzbqc.zzaik(com.google.android.gms:play-services-ads@@19.1.0:13)
       at com.google.android.gms.internal.ads.zzbqc.zzail(com.google.android.gms:play-services-ads@@19.1.0:14)
       at com.google.android.gms.internal.ads.zzboq.zzaih(com.google.android.gms:play-services-ads@@19.1.0:29)
       at com.google.android.gms.internal.ads.zzboq.zzaii(com.google.android.gms:play-services-ads@@19.1.0:49)
       at com.google.android.gms.internal.ads.zzcti.zzg(com.google.android.gms:play-services-ads@@19.1.0:36)
       at com.google.android.gms.internal.ads.zzcti.zza(com.google.android.gms:play-services-ads@@19.1.0:19)
       at com.google.android.gms.internal.ads.zzxv.zza(com.google.android.gms:play-services-ads-lite@@19.1.0:122)
       at com.google.android.gms.ads.BaseAdView.loadAd(com.google.android.gms:play-services-ads-lite@@19.1.0:15)
       at com.google.android.gms.ads.AdView.loadAd(com.google.android.gms:play-services-ads-lite@@19.1.0:20)
       at com.vb.mcpk.screens.mainscreen.fragments.HomeFragment.setUpAddBanner(HomeFragment.java:189)
       at com.vb.mcpk.screens.mainscreen.fragments.HomeFragment.init(HomeFragment.java:319)
       at com.vb.mcpk.screens.mainscreen.fragments.HomeFragment.onCreateView(HomeFragment.java:92)
       at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2600)
       at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:881)
       at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
       at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
       at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2659)
       at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManagerImpl.java:2613)
       at androidx.fragment.app.Fragment.performActivityCreated(Fragment.java:2624)
       at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:904)
       at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1238)
       at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1303)
       at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManagerImpl.java:2659)
       at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManagerImpl.java:2613)
       at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:246)
       at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:542)
       at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:210)
       at com.vb.mcpk.baseclasses.BaseActivity.onStart(BaseActivity.java:224)
       at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1256)
       at android.app.Activity.performStart(Activity.java:6994)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2956)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3064)
       at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:5006)
       at android.app.ActivityThread.-wrap21(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1665)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:154)
       at android.app.ActivityThread.main(ActivityThread.java:6816)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1565)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1453)

junaid Umar

unread,
May 14, 2020, 2:01:48 PM5/14/20
to Google Mobile Ads SDK Developers
66%
Android 9

17%
Android 7

17%
Android 8

Galaxy J5
17%
Galaxy Grand Prime Pro
16%
Galaxy A10

Mobile Ads SDK Forum Advisor Prod

unread,
May 14, 2020, 4:30:28 PM5/14/20
to jjuna...@gmail.com, google-adm...@googlegroups.com
Hi Junaid,

Thank you for bringing this issue to our attention.

I was wondering if we could get more information regarding where this data came from.

If you could share via "Reply privately to author" button with the following infromation that would be greatly appreciated.
  • App id and Ad Unit Id's
  • Any error codes or charles logs for us to look over.
  • A sample app and/or a link to a live app.
  • Any steps needed to reproduce the results that you are seeing.
  • This across all devices or unique devices?

Regards,
William Pescherine

Mobile Ads SDK Team

ref:_00D1U1174p._5004Q1zpPHT:ref

Mahmoud Elfeel

unread,
Jul 5, 2020, 5:56:29 AM7/5/20
to Google Mobile Ads SDK Developers

Screen Shot 2020-07-05 at 11.54.59 AM.png

Here is some useful stats i have been seeing this since forever

Mobile Ads SDK Forum Advisor Prod

unread,
Jul 5, 2020, 10:21:32 PM7/5/20
to mahmoud.e...@gmail.com, google-adm...@googlegroups.com

Hi Mahmoud,

 

Thank you for reaching out to us.

 

Could you kindly provide the details below (via Reply privately to author) so that we can further investigate the issue?

  • Complete stack trace (an OutOfMemoryError is a common error that can produce different stack traces; your issue might be different from the rest of this thread, for example)
  • AdMob SDK version
  • Ad unit ID/s affected

 

Regards,

Ziv Yves Sanchez

Leo Yeung

unread,
Aug 19, 2023, 6:18:23 AM8/19/23
to Google Mobile Ads SDK Developers

Hello fellow developers,

I hope you're all doing well. I wanted to share a recent experience I had while working on an Android application's performance optimization, specifically related to Out Of Memory (OOM) issues caused by a high number of threads. I've come across a potential solution involving bytecode manipulation to modify the SDK's thread pool parameters. While this approach has shown promising results, I'd greatly appreciate your insights and suggestions before proceeding further.

In an effort to tackle the OOM problems associated with excessive threads, I delved into a deep analysis of the issue. It became apparent that adjusting the maxPoolSize and corePoolSize values within the SDK's thread pool might hold promise in mitigating memory-related challenges.

I'm pleased to report that these adjustments have indeed led to noticeable improvements. The application's performance has become more stable, with a significant reduction in OOM instances. However, I'm cautious about the potential implications and adherence to best practices within the Android development landscape.

Given the collective expertise of this community, I kindly request your insights on the following points:

  1. Appropriateness and Compliance: Is the manipulation of bytecode to modify thread pool parameters a legitimate and acceptable approach within the Android development community? Are there any caveats or concerns I should be aware of?

  2. Sustainability: Considering the potential evolution of Android and its SDK, how likely are these bytecode modifications to remain effective across different Android versions and future updates?

  3. Best Practices: Are there any established best practices or recommended methodologies for optimizing thread pool configurations to alleviate OOM issues that you could share?

  4. Alternatives: If my current approach doesn't align with recommended practices, do you have suggestions for alternative strategies to address OOM problems arising from excessive threading?

I highly value your collective insights and experiences. Your input will not only assist me in ensuring the stability and performance of our application but will also contribute to the broader Android development community.

Thank you for taking the time to consider my inquiry. I eagerly await your thoughts and recommendations. Feel free to suggest a convenient time if a deeper discussion would be beneficial.

Best regards,

Leo

Mobile Ads SDK Forum Advisor

unread,
Aug 22, 2023, 11:47:31 AM8/22/23
to leoyeu...@gmail.com, google-adm...@googlegroups.com
Hello,


Thank you for reaching out to us.

Please be informed that this support channel can only best assist you with regards to direct Google Mobile Ads SDK implementation and technical issues. To clarify, is your inquiry with regards to Google Mobile Ads SDK or are you referring to Android SDK?
 
This message is in relation to case "ref:_00D1U1174p._5004Q1zpPHT:ref"

Thanks,
 
Google Logo Mobile Ads SDK Team


Leo Yeung

unread,
Aug 23, 2023, 10:20:09 PM8/23/23
to Google Mobile Ads SDK Developers
Dear AdMob Support Team,

I hope this message finds you well. I am a developer currently integrating the AdMob SDK into my Android application, along with several other third-party SDKs. During the integration process, I have encountered challenges related to thread management and resource utilization, particularly on devices with limited hardware resources.

To provide context, the increased number of threads and thread pools, stemming from the integration of multiple SDKs, has led to the frequent occurrence of `java.lang.OutOfMemoryError: pthread_create (1040KB stack) failed: Try again` on devices with constrained resources. In an effort to mitigate this issue, I have been exploring methods to effectively manage and reuse threads to reduce the strain on memory resources.

While exploring potential solutions, I have noticed that modifying the `maxPoolSize` and `corePoolSize` parameters of thread pools through bytecode manipulation significantly reduces the number of threads and memory consumption. This approach appears to improve the stability and performance of the application on such devices.

However, I am keenly aware of the importance of compliance with your terms of service and any potential anti-cheat mechanisms that might be in place. I want to ensure that my efforts to optimize thread management remain in line with AdMob's guidelines and policies.

I kindly request your guidance on the following matters:

1. Is modifying the `maxPoolSize` and `corePoolSize` parameters of thread pools through bytecode manipulation in compliance with AdMob's terms of service?
2. Are there any potential risks or anti-cheat implications associated with adjusting thread pool parameters in this manner?
3. Could you provide any recommendations or best practices for effectively managing threads while ensuring compliance with AdMob's policies?

I greatly value the insights and expertise of AdMob's team, and I want to ensure that my application's integration with AdMob is both efficient and compliant. Your guidance will be invaluable in helping me make informed decisions about thread management in my application.

Thank you for your time and consideration. I look forward to your response.

Best regards,

Leo

Mobile Ads SDK Forum Advisor

unread,
Aug 24, 2023, 6:43:06 AM8/24/23
to leoyeu...@gmail.com, google-adm...@googlegroups.com
Hi Leo,

Thank you for responding back with the detailed context of your concern. Please see our responses to your following questions below.


1. Is modifying the `maxPoolSize` and `corePoolSize` parameters of thread pools through bytecode manipulation in compliance with AdMob's terms of service?
2. Are there any potential risks or anti-cheat implications associated with adjusting thread pool parameters in this manner?
3. Could you provide any recommendations or best practices for effectively managing threads while ensuring compliance with AdMob's policies?
  • We do have our own optimization guidance which you may check as well here: https://developers.google.com/admob/android/optimize-initialization. Additionally, it is on the developer/publisher discretion/approach to what optimization they would like to add as well. As long as publishers follows the implementation policies mentioned on #1, then there should be no issues.  

mastef ‎

unread,
Nov 2, 2023, 3:54:01 AM11/2/23
to Google Mobile Ads SDK Developers
Possibly related : https://github.com/googleads/googleads-mobile-unity/issues/2996

Also our top error in google play when using the official googleads-mobile-unity package, although the stack traces don't show as much information as above ( stacktraces taken from Google Play Console ).

Also indicates that firebase may be as well affected, although only 1% of stacktraces are related to it.

If maxPoolSize and corePoolSize adjustments are a valid solution, maybe it'd be good for the admob sdk to expose them so we can set the values dynamically / ourselves?

@Leo Young - would be great if you could drop me an email to markus @ superworldbox . com

Thanks

Mobile Ads SDK Forum Advisor

unread,
Nov 2, 2023, 8:08:58 AM11/2/23
to google-adm...@googlegroups.com

Hi,

Thank you for contacting the Mobile Ads SDK support team.

By reviewing your concern, I understand that you are facing an ‘OutOfMemoryError’ issue.

Kindly provide the below information for further investigation:

  • Device/OS versions affected
  • Error Screenshots / video recording
  • Charles proxy logs / network tracing logs

You can provide the following details via reply privately to the author option or directly provide it to the link below.

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=5004Q00002q9uoBQAQ&entry.80707362=00208702

2. Fill out all fields, and attach your file(s).

3. Please reply back to this thread when you have uploaded your file(s). Please do not share this link.

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


Thanks,
 
Google Logo Mobile Ads SDK Team


Message has been deleted

Sebi

unread,
Jan 29, 2024, 5:55:27 AM1/29/24
to Google Mobile Ads SDK Developers

I am also having this issue:
Thread.nativeCreate
java.lang.OutOfMemoryError
java.lang
Thread.java
Caused by java.lang.OutOfMemoryError
pthread_create (1040KB stack) failed: Try again
java.lang.Thread.nativeCreate (Thread.java)
java.lang.Thread.start (Thread.java:733)
java.util.concurrent.ThreadPoolExecutor.addWorker (ThreadPoolExecutor.java:970)
java.util.concurrent.ThreadPoolExecutor.processWorkerExit (ThreadPoolExecutor.java:1038)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1180)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:636)
java.lang.Thread.run (Thread.java:764)

Any solution to this?

Mobile Ads SDK Forum Advisor

unread,
Jan 29, 2024, 12:26:21 PM1/29/24
to exect...@gmail.com, google-adm...@googlegroups.com
Hello,

Thank you for following up. The Android team is still experimenting with a fix. I will report back as soon as I have a further update to share. 

Thanks,
Justin

ref:!00D1U01174p.!5004Q02q9uoB:ref

mec...@gmail.com

unread,
Nov 14, 2024, 5:46:24 AM11/14/24
to Google Mobile Ads SDK Developers
Hello, do we have any news on this front?

Mobile Ads SDK Forum Advisor

unread,
Nov 15, 2024, 10:01:06 AM11/15/24
to mec...@gmail.com, google-adm...@googlegroups.com
Hello,

The engineering team has resolved the issue and the fix will be included in the next Android release after 23.5.0. 
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02q9uoB:ref" (ADR-00208702)

Thanks,
 
Google Logo
Justin Malandruccolo
Mobile Ads SDK Team


Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages