Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6144367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:38:21+00:00 2026-05-23T18:38:21+00:00

Found a way to return complex models (Object with sub objects and ArrayList with

  • 0

Found a way to return complex models (Object with sub objects and ArrayList with Object items) from C to Java. But I have another problem: Memory leaks.

Currently, the code I’m working on is parsing a data (on C) and should return the data parsed to a Java Class.

The main Java Class contains more Java Classes (ints, String, boolean, Obj, ArrayList of Objects), and I’m returning the parsed data using this pattern for Object instances:

    // Instance:LyricsLineVo
    jclass findClsLyricsLine = (*env)->FindClass(env, "com/example/jni/vo/LyricsLineVo");
    jmethodID initLyricsLine = (*env)->GetMethodID (env, findClsLyricsLine, initMethod,"()V");
    jobject objLyricsLine = (*env)->NewObject(env, findClsLyricsLine, initLyricsLine);
    jclass classLyricsLine = (*env)->GetObjectClass(env, objLyricsLine);

The code’s too long and I don’t know if I should separate other objects to another function and just pass the parsed data to each different functions, I think it would consume more memory and I’m already having issues on freeing used ones.

I’ve read some ways on how to free spaces:

Memory leak using JNI to retrieve String's value from Java code

Memory leak when calling java code from C using JNI

But applying those aren’t enough. It can only allow one parsing of data but after that, my program’s crashing.

Are there any other recommended codes that can reduce memory usage for this?

I’m adding my error log below:

    07-11 19:23:31.640: WARN/dalvikvm(301): ReferenceTable overflow (max=512)
    07-11 19:23:31.650: WARN/dalvikvm(301): Last 10 entries in JNI local reference table:
    07-11 19:23:31.650: WARN/dalvikvm(301): 502: 0x44df0930 cls=Ljava/lang/Class; 'Lcom/demo/project/vo/DurationVo;' (172 bytes)
    07-11 19:23:31.650: WARN/dalvikvm(301): 503: 0x44df51a8 cls=Lcom/demo/project/vo/DurationVo; (20 bytes)
    07-11 19:23:31.660: WARN/dalvikvm(301): 504: 0x44df0930 cls=Ljava/lang/Class; 'Lcom/demo/project/vo/DurationVo;' (172 bytes)
    07-11 19:23:31.660: WARN/dalvikvm(301): 505: 0x4002afc8 cls=Ljava/lang/Class; 'Ljava/util/ArrayList;' (172 bytes)
    07-11 19:23:31.660: WARN/dalvikvm(301): 506: 0x44df5280 cls=Ljava/util/ArrayList; (28 bytes)
    07-11 19:23:31.660: WARN/dalvikvm(301): 507: 0x44df0338 cls=Ljava/lang/Class; 'Lcom/demo/project/vo/MeasureTrackPairVo;' (172 bytes)
    07-11 19:23:31.660: WARN/dalvikvm(301): 508: 0x44df52a0 cls=Lcom/demo/project/vo/MeasureTrackPairVo; (28 bytes)
    07-11 19:23:31.660: WARN/dalvikvm(301): 509: 0x44df0338 cls=Ljava/lang/Class; 'Lcom/demo/project/vo/MeasureTrackPairVo;' (172 bytes)
    07-11 19:23:31.660: WARN/dalvikvm(301): 510: 0x4002afc8 cls=Ljava/lang/Class; 'Ljava/util/ArrayList;' (172 bytes)
    07-11 19:23:31.660: WARN/dalvikvm(301): 511: 0x44df5320 cls=Ljava/util/ArrayList; (28 bytes)
    07-11 19:23:31.680: WARN/dalvikvm(301): JNI local reference table summary (512 entries):
    07-11 19:23:31.690: WARN/dalvikvm(301): 322 of Ljava/lang/Class; 172B (11 unique)
    07-11 19:23:31.690: WARN/dalvikvm(301): 7 of Ljava/lang/Integer; 12B (7 unique)
    07-11 19:23:31.690: WARN/dalvikvm(301): 10 of Ljava/lang/String; 28B (10 unique)
    07-11 19:23:31.690: WARN/dalvikvm(301): 33 of Ljava/util/ArrayList; 28B (33 unique)
    07-11 19:23:31.690: WARN/dalvikvm(301): 1 of Lcom/demo/project/vo/HeaderVo; 60B
    07-11 19:23:31.700: WARN/dalvikvm(301): 1 of Lcom/demo/project/vo/LyricsVo; 20B
    07-11 19:23:31.700: WARN/dalvikvm(301): 1 of Lcom/demo/project/vo/LyricsLineVo; 20B
    07-11 19:23:31.700: WARN/dalvikvm(301): 18 of Lcom/demo/project/vo/MeasureHeaderVo; 36B (18 unique)
    07-11 19:23:31.710: WARN/dalvikvm(301): 1 of Lcom/demo/project/vo/TrackHeaderVo; 60B
    07-11 19:23:31.710: WARN/dalvikvm(301): 14 of Lcom/demo/project/vo/MeasureTrackPairVo; 28B (14 unique)
    07-11 19:23:31.710: WARN/dalvikvm(301): 52 of Lcom/demo/project/vo/BeatVo; 60B (52 unique)
    07-11 19:23:31.710: WARN/dalvikvm(301): 52 of Lcom/demo/project/vo/DurationVo; 20B (52 unique)
    07-11 19:23:31.710: WARN/dalvikvm(301): Memory held directly by native code is 8540 bytes
    07-11 19:23:31.720: ERROR/dalvikvm(301): Failed adding to JNI local ref table (has 512 entries)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:38:22+00:00Added an answer on May 23, 2026 at 6:38 pm

    I’m using

          (*env)->DeleteLocalRef(env, classLyricsLine);
          (*env)->DeleteLocalRef(env, objLyricsLine);
          (*env)->DeleteLocalRef(env, findClsLyricsLine);
    

    And it seems to have solved the problem for ReferenceTable overflow. However, I’m getting another error NOT because of so many object instances but because of accessing data.

    i.e.

         Song *song  // struct.
         ....
         song->measureTracks[m][n].beats[0].notes[0].noteEffects->bend->bendPoints
    

    Sample error log:

            07-14 16:57:00.725: INFO/DEBUG(28): Build fingerprint: 'generic/sdk/generic/:2.1-update1/ECLAIR/35983:eng/test-keys'
            07-14 16:57:00.725: INFO/DEBUG(28): pid: 297, tid: 307  >>> com.synapticstuff.guitartabs <<<
            07-14 16:57:00.735: INFO/DEBUG(28): signal 11 (SIGSEGV), fault addr 0000001c
            07-14 16:57:00.735: INFO/DEBUG(28): r0 00000034  r1 00127f28  r2 00000000  r3 00000000
            07-14 16:57:00.735: INFO/DEBUG(28): r4 80a06ad4  r5 ad02cab9  r6 41878d20  r7 41867de4
            07-14 16:57:00.735: INFO/DEBUG(28): r8 46d68d50  r9 41867ddc  10 41867dc4  fp 00139838
            07-14 16:57:00.735: INFO/DEBUG(28): ip ad080214  sp 46d68a30  lr ad03bad1  pc 80a02bb2  cpsr 00000030
            07-14 16:57:00.905: INFO/DEBUG(28): #00  pc 00002bb2  /data/data/com.synapticstuff.guitartabs/lib/libgpparser.so
            07-14 16:57:00.915: INFO/DEBUG(28): #01  pc 0000f1f4  /system/lib/libdvm.so
            07-14 16:57:00.915: INFO/DEBUG(28): #02  pc 00038018  /system/lib/libdvm.so
            07-14 16:57:00.925: INFO/DEBUG(28): #03  pc 000316a2  /system/lib/libdvm.so
            07-14 16:57:00.925: INFO/DEBUG(28): #04  pc 0003d31c  /system/lib/libdvm.so
            07-14 16:57:00.925: INFO/DEBUG(28): #05  pc 00013f58  /system/lib/libdvm.so
            07-14 16:57:00.925: INFO/DEBUG(28): #06  pc 00019888  /system/lib/libdvm.so
            07-14 16:57:00.935: INFO/DEBUG(28): #07  pc 00018d5c  /system/lib/libdvm.so
            07-14 16:57:00.935: INFO/DEBUG(28): #08  pc 0004d6d0  /system/lib/libdvm.so
            07-14 16:57:00.945: INFO/DEBUG(28): #09  pc 0004d702  /system/lib/libdvm.so
            07-14 16:57:00.945: INFO/DEBUG(28): #10  pc 00041c78  /system/lib/libdvm.so
            07-14 16:57:00.945: INFO/DEBUG(28): #11  pc 00010000  /system/lib/libc.so
            07-14 16:57:00.955: INFO/DEBUG(28): #12  pc 0000fad4  /system/lib/libc.so
            07-14 16:57:00.955: INFO/DEBUG(28): code around pc:
            07-14 16:57:00.975: INFO/DEBUG(28): 80a02ba0 68d918d3 1c139a2e 189b009b 18cb00db
            07-14 16:57:00.975: INFO/DEBUG(28): 80a02bb0 7f1b6a5b 9b05931c 23bc681a 58d5005b
            07-14 16:57:00.975: INFO/DEBUG(28): 80a02bc0 99259805 447b4b8c 4b8c1c1a 47a8447b
            07-14 16:57:00.975: INFO/DEBUG(28): code around lr:
            07-14 16:57:00.975: INFO/DEBUG(28): ad03bac0 18282200 f890f7f9 21079802 ffcef004
            07-14 16:57:01.042: INFO/DEBUG(28): ad03bad0 1c30b005 46c0bdf0 000444c8 fffe57c4
            07-14 16:57:01.045: INFO/DEBUG(28): ad03bae0 fffea17e fffea125 6900b5f0 1c0db087
            07-14 16:57:01.045: INFO/DEBUG(28): stack:
            07-14 16:57:01.055: INFO/DEBUG(28): 46d689f0  00129300  [heap]
            07-14 16:57:01.055: INFO/DEBUG(28): 46d689f4  44e0eab8  /dev/ashmem/mspace/dalvik-heap/2 (deleted)
            07-14 16:57:01.065: INFO/DEBUG(28): 46d689f8  80a056d8  /data/data/com.synapticstuff.guitartabs/lib/libgpparser.so
            07-14 16:57:01.065: INFO/DEBUG(28): 46d689fc  ad02cb49  /system/lib/libdvm.so
            07-14 16:57:01.065: INFO/DEBUG(28): 46d68a00  ad038f65  /system/lib/libdvm.so
            07-14 16:57:01.076: INFO/DEBUG(28): 46d68a04  00129300  [heap]
            07-14 16:57:01.076: INFO/DEBUG(28): 46d68a08  44e0eb68  /dev/ashmem/mspace/dalvik-heap/2 (deleted)
            07-14 16:57:01.076: INFO/DEBUG(28): 46d68a0c  ad02a095  /system/lib/libdvm.so
            07-14 16:57:01.076: INFO/DEBUG(28): 46d68a10  80a06ad4  /data/data/com.synapticstuff.guitartabs/lib/libgpparser.so
            07-14 16:57:01.085: INFO/DEBUG(28): 46d68a14  80a05090  /data/data/com.synapticstuff.guitartabs/lib/libgpparser.so
            07-14 16:57:01.085: INFO/DEBUG(28): 46d68a18  ad02d935  /system/lib/libdvm.so
            07-14 16:57:01.085: INFO/DEBUG(28): 46d68a1c  80a06ad4  /data/data/com.synapticstuff.guitartabs/lib/libgpparser.so
            07-14 16:57:01.085: INFO/DEBUG(28): 46d68a20  ad02cab9  /system/lib/libdvm.so
            07-14 16:57:01.085: INFO/DEBUG(28): 46d68a24  41878d20  /dev/ashmem/dalvik-LinearAlloc (deleted)
            07-14 16:57:01.085: INFO/DEBUG(28): 46d68a28  df002777
            07-14 16:57:01.085: INFO/DEBUG(28): 46d68a2c  e3a070ad
            07-14 16:57:01.095: INFO/DEBUG(28): #00 46d68a30  00000000
            07-14 16:57:01.095: INFO/DEBUG(28): 46d68a34  3fe00000
            07-14 16:57:01.095: INFO/DEBUG(28): 46d68a38  44dfe710  /dev/ashmem/mspace/dalvik-heap/2 (deleted)
            07-14 16:57:01.095: INFO/DEBUG(28): 46d68a3c  44dfe9a8  /dev/ashmem/mspace/dalvik-heap/2 (deleted)
            07-14 16:57:01.095: INFO/DEBUG(28): 46d68a40  44dfe1b0  /dev/ashmem/mspace/dalvik-heap/2 (deleted)
            07-14 16:57:01.095: INFO/DEBUG(28): 46d68a44  00129300  [heap]
            07-14 16:57:01.095: INFO/DEBUG(28): 46d68a48  44dfede8  /dev/ashmem/mspace/dalvik-heap/2 (deleted)
            07-14 16:57:01.095: INFO/DEBUG(28): 46d68a4c  ffffffff
            07-14 16:57:01.095: INFO/DEBUG(28): 46d68a50  00000073
            07-14 16:57:01.095: INFO/DEBUG(28): 46d68a54  00000009
            07-14 16:57:01.105: INFO/DEBUG(28): 46d68a58  46d68cc4
            07-14 16:57:01.105: INFO/DEBUG(28): 46d68a5c  afe38e08  /system/lib/libc.so
            07-14 16:57:01.105: INFO/DEBUG(28): 46d68a60  46d68aac
            07-14 16:57:01.105: INFO/DEBUG(28): 46d68a64  fffffff7
            07-14 16:57:01.105: INFO/DEBUG(28): 46d68a68  ad06aae8  /system/lib/libdvm.so
            07-14 16:57:01.105: INFO/DEBUG(28): 46d68a6c  ad07ff50  /system/lib/libdvm.so
    

    What seems to be the problem now?
    I’ve already prepared all the object instances but everytime I try to use the actual struct song with data if it’s too far, it crashes. Even if I get just part of the struct:

        NoteEffects *noteEffects = song->measureTracks[m][n].beats[0].notes[0].noteEffects
        // then use noteEffects.bend
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have found the way to copy the record that I would like, but
I found a way to write avi from BMP files: http://www.delphi3000.com/articles/article_2770.asp?SK= I want to
okay i have found the way to run a video in a image.... the
I have researched and haven't found a way to run INTERSECT and MINUS operations
I learned something about DLL's yesterday. But I haven't found the way how to
After lots of attempts and search I have never found a satisfactory way to
I finally thought I had found a way to acutally use excel productively but
Is it possible to have a class object return a true/false value, so I
I'm trying to access a view in this way: return View(@~\Items\Details.aspx); and I get
Via reflection I have found a lists of properties from x POJO classes which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.