title: Native shared library loaded to slow in Android
body: <p>I have a shared library placed in libs/armeabi folder. It is loaded using</p>
  
  <pre><code>System.loadLibrary("library_name.so");
  </code></pre>
  
  <p>The size of the library is around 3MB. The loading time is very long. It sometimes last almost 20 seconds. It blocks my GUI. I tried to put <code>System.loadLibrary("library_name.so");</code> in a different thread but my GUI is still blocked. I know that others apps use even bigger .so files, but the loading time is not so big. What could be the problem?</p>
  
  <p>EDIT</p>
  
  <p>3MB was the size of the debug version. Release version is about 800KB, but the problem is the same. Some additional info:</p>
  
  <ul>
  <li>.so contains my two c++ libraries which are circularly connected</li>
  <li>running <code>arm-linux-androideabi-nm -D -C -g library_name.so</code> displays a lot of functions and variables</li>
  <li>I don't use <code>LOCAL_WHOLE_STATIC_LIBRARIES</code> anymore</li>
  <li>here are the section headers table obtained by using <code>arm-linux-androideabi-readelf-tool</code>:</li>
  </ul>
  
  <blockquote>
  <pre><code>Section Headers:
    [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  
    [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  
    [ 1] .dynsym           DYNSYM          00000114 000114 00b400 10   A  2   1  4
  
    [ 2] .dynstr           STRTAB          0000b514 00b514 015b0c 00   A  0   0  1
  
    [ 3] .hash             HASH            00021020 021020 004d1c 04   A  1   0  4
  
    [ 4] .rel.dyn          REL             00025d3c 025d3c 006e98 08   A  1   0  4
  
    [ 5] .rel.plt          REL             0002cbd4 02cbd4 000468 08   A  1   6  4
  
    [ 6] .plt              PROGBITS        0002d03c 02d03c 0006b0 00  AX  0   0  4
  
    [ 7] .text             PROGBITS        0002d6f0 02d6f0 08e6e0 00  AX  0   0  8
  
    [ 8] .ARM.extab        PROGBITS        000bbdd0 0bbdd0 00bad0 00   A  0   0  4
  
    [ 9] .ARM.exidx        ARM_EXIDX       000c78a0 0c78a0 005b80 08  AL  7   0  4
  
    [10] .rodata           PROGBITS        000cd420 0cd420 005cc0 00   A  0   0  4
  
    [11] .data.rel.ro.loca PROGBITS        000d46d8 0d36d8 0006e4 00  WA  0   0  4
  
    [12] .fini_array       FINI_ARRAY      000d4dbc 0d3dbc 000008 00  WA  0   0  4
  
    [13] .init_array       INIT_ARRAY      000d4dc4 0d3dc4 00009c 00  WA  0   0  4
  
    [14] .data.rel.ro      PROGBITS        000d4e60 0d3e60 00384c 00  WA  0   0  8
  
    [15] .dynamic          DYNAMIC         000d86ac 0d76ac 000100 08  WA  2   0  4
  
    [16] .got              PROGBITS        000d87ac 0d77ac 000854 00  WA  0   0  4
  
    [17] .data             PROGBITS        000d9000 0d8000 000648 00  WA  0   0  8
  
    [18] .bss              NOBITS          000d9648 0d8648 047271 00  WA  0   0  8
  
    [19] .comment          PROGBITS        00000000 0d8648 000026 01  MS  0   0  1
  
    [20] .note.gnu.gold-ve NOTE            00000000 0d8670 00001c 00      0   0  4
  
    [21] .ARM.attributes   ARM_ATTRIBUTES  00000000 0d868c 00002d 00      0   0  1
  
    [22] .shstrtab         STRTAB          00000000 0d86b9 0000d8 00      0   0  1
  </code></pre>
  </blockquote>