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

  • SEARCH
  • Home
  • 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 3346210
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:16:36+00:00 2026-05-18T01:16:36+00:00

Perhaps I am attempting to do something I ought not. I’m running a block

  • 0

Perhaps I am attempting to do something I ought not.

I’m running a block of code in the emulator. It looks (more or less)
like this: http://pastie.org/1291380

This is to construct a live wallpaper background. I pass in a bitmap,
color palette, and tile array.The size of my bitmap is 256 x 256.
getRedPal / getGreenPal / getBluePal essentially does a call to
Color.red() / Color.green() / Color.blue() in order to get the rgb
color components of a palette object.

The loops chug along; I get all the way to the point where the j value
of drawInC hits 32, before the emulator crashes and burns:

11-11 15:34:44.032: INFO/distort_bmp(598): DrawInC: i: 0 j: 32

11-11 15:34:44.032: INFO/distort_bmp(598): DrawTiles: i: 0 j: 0

11-11 15:34:44.032: INFO/distort_bmp(598): DrawTiles: i: 0 j: 1

11-11 15:34:44.032: INFO/distort_bmp(598): DrawTiles: i: 0 j: 2

11-11 15:34:44.032: INFO/distort_bmp(598): DrawTiles: i: 0 j: 3

11-11 15:34:44.032: INFO/distort_bmp(598): DrawTiles: i: 0 j: 4

After which I get a dump file sent to /data/tombstones . Here is the
dump (but I sincerely don’t find anything in it worth any value, just
a bunch of memory addresses): http://pastie.org/1291394

I added android:vmSafeMode=”true” to my tag after
reading elsewhere that that could solve a problem. This is on 2.2,
using bitmap.h.

Personally I am dubious of that

jbyte* buffer = 
(*env)->GetByteArrayElements(env, arr, &isCopy)

call; I plucked that
code from the net somewhere, as I was totally unable to get values
from my byte array “arr.”

Any ideas?

EDIT
After manipulating my loop iterators (I shortened the number of loops), I now get an informative error:

“ReferenceTable overflow (max=512)”

JNI local reference table summary (512 entries):
  509 of Ljava/lang/Class; 164B (3 unique)
2 of Ljava/lang/String; 28B (2 unique)
   1 of [Ljava/lang/String; 28B
Memory held directly by tracked refs is 576 bytes
Failed adding to JNI local ref table (has 512 entries)

That “509 of java.lang.class” doesn’t look too right to me…how can I optimize my code here?

  • 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-18T01:16:36+00:00Added an answer on May 18, 2026 at 1:16 am

    From that error message, it appears that some bit of native code has called a function that returns a Class object, and has done so 509 times. 507 of those calls returned one particular class.

    JNI local references let the GC know that native code is looking at an object, and therefore that object can’t be collected even if there are no references to it elsewhere. These local refs are released when the native code returns to the VM. If the native code does a lot of work without returning, it’s possible to overflow the local ref table.

    You probably just need to add a DeleteLocalRef somewhere. My guess is you need to add one at the end of DrawTile, because of the GetObjectClass call. Better yet, move those GetMethodID calls to a one-time setup function. (They do string searches to find the method, making them not especially quick.)

    For more info see JNI Tips.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.