Why are the "Code" and "Native" sections in the Memory Profiler using too much memory and how can I reduce it?

My application uses 75 MB of memory the first time a user opens it.

I used the Android Profiler Tool from Android Studio to learn how to use my Android app. When the main screen opens, the application will begin to use 75 MB of memory, even if the main activity does not create an object that requires too much memory. No bitmaps or large arrays, etc.

40MB is in the "Code" section, and 19MB is from "Native", which we do not upload to this activity. However, we load when the user opens another activity. I am trying to reduce memory usage, and I was wondering how I can reduce from the "Code" and "Native" sections.

Screenshot with Android Profiler

enter image description here

+4
source share
1 answer

About nativememory usage:

  • Android , 0 , . "" . , , Activity Button, - 18 , , 8 . Android Studio, " " . , , .

  • Java - ByteBuffer.allocateDirect(int).

  • , - Activity, ( static { }), , , . , . , C, , . , , , . - .

__attribute__((constructor)) void init(void) { int a = *(int *) ((void *) 0); }

code, :)

, minifyEnabled true , , :

    ...
    buildTypes {
        debug {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    ...

(. "" ).

+3

Source: https://habr.com/ru/post/1694283/


All Articles