3

In my android application I call a native function frequently which returns some data. After a number of calls I received a crash showing following trace.

W/dalvikvm(14588): ReferenceTable overflow (max=1024)
W/dalvikvm(14588): Last 10 entries in JNI pinned array reference table:
W/dalvikvm(14588):  1014: 0x41f3b7a8 cls=[B (38036 bytes)
W/dalvikvm(14588):  1015: 0x411c6f88 cls=[B (1620 bytes)
W/dalvikvm(14588):  1016: 0x405b2f48 cls=[B (1052 bytes)
W/dalvikvm(14588):  1017: 0x411c4be0 cls=[B (92 bytes)
W/dalvikvm(14588):  1018: 0x41f44c40 cls=[B (38036 bytes)
W/dalvikvm(14588):  1019: 0x411c5a78 cls=[B (60 bytes)
W/dalvikvm(14588):  1020: 0x413ac4e8 cls=[B (38036 bytes)
W/dalvikvm(14588):  1021: 0x411c7970 cls=[B (52 bytes)
W/dalvikvm(14588):  1022: 0x41e2b1b0 cls=[B (38036 bytes)
W/dalvikvm(14588):  1023: 0x407e06c8 cls=[B (60 bytes)
W/dalvikvm(14588): JNI pinned array reference table summary (1024 entries):
W/dalvikvm(14588):    90 of [B 36B (90 unique)
W/dalvikvm(14588):   127 of [B 44B (127 unique)
W/dalvikvm(14588):    63 of [B 52B (63 unique)
W/dalvikvm(14588):    78 of [B 60B (78 unique)
W/dalvikvm(14588):    50 of [B 68B (50 unique)
W/dalvikvm(14588):    30 of [B 76B (30 unique)
W/dalvikvm(14588):    15 of [B 84B (15 unique)
W/dalvikvm(14588):    18 of [B 92B (18 unique)
W/dalvikvm(14588):    11 of [B 100B (11 unique)
W/dalvikvm(14588):     9 of [B 108B (9 unique)
W/dalvikvm(14588):     4 of [B 116B (4 unique)
W/dalvikvm(14588):     5 of [B 132B (5 unique)
W/dalvikvm(14588):     1 of [B 140B
W/dalvikvm(14588):     4 of [B 156B (4 unique)
W/dalvikvm(14588):     1 of [B 180B
W/dalvikvm(14588):     1 of [B 204B
W/dalvikvm(14588):     1 of [B 212B
W/dalvikvm(14588):     2 of [B 244B (2 unique)
W/dalvikvm(14588):     1 of [B 332B
W/dalvikvm(14588):     1 of [B 1044B
W/dalvikvm(14588):     1 of [B 1052B
W/dalvikvm(14588):     1 of [B 1620B
W/dalvikvm(14588):   510 of [B 38036B (510 unique)
W/dalvikvm(14588): Memory held directly by tracked refs is 19432832 bytes
E/dalvikvm(14588): Failed adding to JNI pinned array ref table (1024 entries)

I have released the byte array used namely ReleaseByteArrayElements. one of the native function code block

jbyte *inArray = (*env)->GetByteArrayElements(env,datay,JNI_FALSE);
jbyte *outArray = (*env)->GetByteArrayElements(env, datah,JNI_FALSE);
int size=(*env)->GetArrayLength(env,hdata);
....
      unsigned char *data=outArray;
     memcpy(data,outbuf,out_size);
    (*env)->ReleaseByteArrayElements(env, datay, inArray,JNI_FALSE);
    (*env)->ReleaseByteArrayElements(env, datah, outArray,JNI_FALSE);
    data=NULL;

any idea?

Sureshkumar Menon
  • 1,165
  • 7
  • 27
  • 49
  • 1
    Without knowing much about Android and JNI, I'd say a memory leak. Your C function probably allocates something and never released (and it's C, therefore not covered by garbage collection). – ugoren Feb 21 '12 at 12:01
  • Do you create global references with NewGlobalRef() ? – olivierg Feb 21 '12 at 13:18
  • 1
    I have solved the memory leak issue.It was my mistake didn't observe the code properly. Finally release the memory. – Sureshkumar Menon Feb 23 '12 at 10:47
  • @newentry how to release the memory using JNI or any other method? http://stackoverflow.com/questions/10942929/viewpager-webview-memory-issue/10943022#10943022 – LOG_TAG Jun 12 '12 at 14:33

0 Answers0