Android App Startup Problems (Growing Heap)

感情迁移 提交于 2020-02-06 16:44:06

问题


I have a very big Problem with our App. We need much space for Bitmap transformation, but directly at Startup (of the App) most of the Memory gets Allocated with unknown Stuff... Below you can find the Console Output from Xamarin Studio. What could possibly trigger such big allocations? The App is tested on different devices, the Output below is from the Worst One (Samsung Galaxy S3)

This is my OnCreate of MainActivity:

protected override void OnCreate(Bundle bundle)
{
    base.OnCreate(bundle);
    SetContentView(Resource.Layout.Main);
}

Console Output:

Forwarding debugger port 8808
Detecting existing process
Loaded assembly: /storage/emulated/0/Android/data/com.#AppName#.#AppName#/files        /.__override__/#AppName#.dll
Loaded assembly: Mono.Android.dll [External]
Loaded assembly: System.Core.dll [External]
Loaded assembly: MonoDroidConstructors [External]
[monodroid-debug] Trying to initialize the debugger with options: --debugger-    agent=transport=dt_socket,loglevel=0,address=127.0.0.1:8808,server=y,embedding=1
[libc] WARNING: generic atexit() called from legacy shared library
[Mono] Image addref mscorlib[0x57bc76f0] -> mscorlib.dll[0x41d0f588]: 1
[Mono] AOT module 'mscorlib.dll.so' not found: dlopen failed: library "/data        /data/com.#AppName#.#AppName#/lib/mscorlib.dll.so" not found
[Mono] Assembly mscorlib[0x57bc76f0] added to domain RootDomain, ref_count=1
[Mono] Assembly Loader probing location: '/storage/emulated/0/Android        /data/com.#AppName#.#AppName#/files/.__override__/#AppName#.dll'.
[Mono] Image addref #AppName#[0x57bc9dd8] -> /storage/emulated/0/Android        /data/com.#AppName#.#AppName#/files/.__override__/#AppName#.dll[0x57bc9008]: 2
[Mono] Assembly #AppName#[0x57bc9dd8] added to domain RootDomain, ref_count=1
[Mono] AOT module '/storage/emulated/0/Android/data/com.#AppName#.#AppName#/files/.__override__/#AppName#.dll.so' not found: dlopen failed: library "/data    /data/com.#AppName#.#AppName#/lib//storage/emulated/0/Android/data/com.#AppName#.#AppName#/files/.__override__/#AppName#.dll.so" not found
[Mono] Assembly Loader loaded assembly from location: '/storage/emulated/0/Android/data/com.#AppName#.#AppName#/files/.__override__/#AppName#.dll'.
[Mono] Config attempting to parse: '/storage/emulated/0/Android/data/com.#AppName#.#AppName#/files/.__override__/#AppName#.dll.config'.
[Mono] Config attempting to parse: '/Users/builder/data/lanes/1131/2a7b6821/source/monodroid/builds/install/mono-armv7/etc/mono/assemblies/#AppName#/#AppName#.config'.
[monodroid-gc] GREF GC Threshold: 46800
[Mono] Image addref Mono.Android[0x57bcac10] -> Mono.Android.dll[0x57bca250]: 1
[Mono] Assembly Mono.Android[0x57bcac10] added to domain RootDomain, ref_count=1
[Mono] AOT module 'Mono.Android.dll.so' not found: dlopen failed: library "/data/data/com.#AppName#.#AppName#/lib/Mono.Android.dll.so" not found
[Mono] Assembly Ref addref Mono.Android[0x57bcac10] -> mscorlib[0x57bc76f0]: 2
[Mono] Image addref System.Core[0x59182658] -> System.Core.dll[0x59181a40]: 1
[Mono] Assembly System.Core[0x59182658] added to domain RootDomain, ref_count=1
[Mono] AOT module 'System.Core.dll.so' not found: dlopen failed: library "/data/data/com.#AppName#.#AppName#/lib/System.Core.dll.so" not found
[Mono] Assembly Ref addref Mono.Android[0x57bcac10] -> System.Core[0x59182658]: 2
[Mono] Assembly Ref addref System.Core[0x59182658] -> mscorlib[0x57bc76f0]: 3
[Mono] Assembly Ref addref #AppName#[0x57bc9dd8] -> Mono.Android[0x57bcac10]: 2
[Mono] DllImport attempting to load: '__Internal'.
[Mono] DllImport loaded library '(null)'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for '_monodroid_gc_wait_for_bridge_processing'.
[Mono] Probing '_monodroid_gc_wait_for_bridge_processing'.
[Mono] Found as '_monodroid_gc_wait_for_bridge_processing'.
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for '_monodroid_get_identity_hash_code'.
[Mono] Probing '_monodroid_get_identity_hash_code'.
[Mono] Found as '_monodroid_get_identity_hash_code'.
[Mono] Assembly Ref addref #AppName#[0x57bc9dd8] -> mscorlib[0x57bc76f0]: 4
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for '_monodroid_gref_log_new'.
[Mono] Probing '_monodroid_gref_log_new'.
[Mono] Found as '_monodroid_gref_log_new'.
[dalvikvm-heap] Grow heap (frag case) to 12.344MB for 2005072-byte allocation
[dalvikvm-heap] Grow heap (frag case) to 19.993MB for 8020240-byte allocation
[dalvikvm-heap] Grow heap (frag case) to 32.004MB for 11632656-byte allocation
[Mono] DllImport searching in: '__Internal' ('(null)').
[Mono] Searching for '_monodroid_gref_log_delete'.
[Mono] Probing '_monodroid_gref_log_delete'.
[Mono] Found as '_monodroid_gref_log_delete'.

Thank you for your Help!

Edit:

Using LargeHeap in Manifest does not Help. And when I load the App without a Layout at All, the Heap Size is also growing to 19mb.


回答1:


You got one line of code that can possibly cause that memory allocation if you are not using a custom Application class and that is setContentView(). You may have big images on your Layout xml or too many images.Try to simplify your layout xml or use smaller images.If you are not getting out of memory exception you don't need to change this; however you will need more space for image operations so you can do this(But this is not recommended):android:largeHeap="true"




回答2:


I found the Problem. In my drawable Folder was not the correct Icon.png. The Icon I used had a Resolution of 708x708. I replaced it with a smaller one, now it works... Thank you Ercan for pushing me in the right direction.



来源:https://stackoverflow.com/questions/25886168/android-app-startup-problems-growing-heap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!