gpt4 book ai didi

java - android:加载文本已更改的布局时崩溃

转载 作者:行者123 更新时间:2023-12-02 13:26:51 28 4
gpt4 key购买 nike

我有一个布局,每行包含图像和 5 个字符的文本。当我连续加载此布局大约 50-100 次时,应用程序崩溃了。 -我只是启动此布局的 Activity ,按返回并使用不同的参数再次启动它等等..

我加载相同的布局,但每次 50-100 次都有在 onCreate 代码中设置的不同图像和文本

编译器成功到达 onCreate 代码的末尾。

分配有什么问题?

为什么分配失败?

我能知道谁是有问题的字符串吗?

我该如何解决这个问题?

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.sampleapp, PID: 24414
java.lang.OutOfMemoryError: Failed to allocate a 566582 byte allocation with 326088 free bytes and 318KB until OOM
at java.lang.StringFactory.newStringFromChars(Native Method)
at java.lang.AbstractStringBuilder.toString(AbstractStringBuilder.java:629)
at java.lang.StringBuilder.toString(StringBuilder.java:663)
at org.chromium.content_public.browser.LoadUrlParams.buildDataUri(LoadUrlParams.java:113)
at org.chromium.content_public.browser.LoadUrlParams.createLoadDataParamsWithBaseUrl(LoadUrlParams.java:164)
at org.chromium.android_webview.AwContents.loadDataWithBaseURL(AwContents.java:1460)
at com.android.webview.chromium.WebViewChromium.loadDataWithBaseURL(WebViewChromium.java:609)
at android.webkit.WebView.loadDataWithBaseURL(WebView.java:978)
at com.facebook.ads.internal.adapters.h.a(Unknown Source)
at com.facebook.ads.internal.adapters.h.loadBannerAd(Unknown Source)
at com.facebook.ads.internal.DisplayAdController.a(Unknown Source)
at com.facebook.ads.internal.DisplayAdController.o(Unknown Source)
at com.facebook.ads.internal.DisplayAdController.d(Unknown Source)
at com.facebook.ads.internal.DisplayAdController$5.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

最佳答案

似乎存在内存泄漏,因为您的应用程序未正确处理 fb 库,或者可能是 fb 库存在问题。您需要使用分析您的应用程序

https://developer.android.com/studio/profile/am-memory.html

Android Monitor provides a Memory Monitor so you can more easily monitor app performance and memory usage to find deallocated objects, locate memory leaks, and track the amount of memory the connected device is using. The Memory Monitor reports how your app allocates memory and helps you to visualize the memory your app uses. It lets you:

关于java - android:加载文本已更改的布局时崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43356904/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com