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 6703293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:09:15+00:00 2026-05-26T07:09:15+00:00

I have a method with following JNI method JNIEXPORT void JNICALL Java_com_android_Coordinates_Updates ( JNIEnv

  • 0

I have a method with following JNI method

JNIEXPORT void JNICALL Java_com_android_Coordinates_Updates
(
JNIEnv * env,
jobject obj,
jobjectArray coordinates
)
    {
    int size = env->GetArrayLength(coordinates);

    for(int i = 0; i < size; i ++)
        {
        jfloatArray row = (jfloatArray)env->GetObjectArrayElement(coordinates, i);
        jfloat *elements = env->GetFloatArrayElements(row , 0);

        //Do I need to release this or any other memory?
        env->ReleaseFloatArrayElements( row , (jfloat *)elements, i);
        }  
    }

My question is do I need to release any memory in this case?

I am asking this question because I have an Android app that passes small data(touch coordinates) with a fast pace from Java to JNI. When I move two fingers over my android device in fast speed, app crashes in under 15 seconds. I tried to narrow down the problem and came to the point where if I include line given below in method above app crashes, otherwise it doesn’t.

jfloat *elements = env->GetFloatArrayElements(row , 0);
  • 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-26T07:09:16+00:00Added an answer on May 26, 2026 at 7:09 am

    Yes. You need to call ReleaseXxxxArrayElement() when you have used GetXxxxArrayElements() to undo the work.

    // why did you use "i" ?
    env->ReleaseFloatArrayElements( row , (jfloat *)elements, 0);
    // we cleanup local ref due to looping ("size" might be large!)
    env->DeleteLocalRef(row);
    

    Do you have an array of an array ? My guess below is what application code might looks like based on what I see in your problem, please modify it repost into the question.

    Float[] firstElement = new Float[2];
    firstElement[0] = 1.0f;   // x value 
    firstElement[1] = 42.0f;  // y value
    
    Object[] coordinates = new Object[1];
    coordinates[0] = firstElement;
    
    com.android.Coordinates coordObject = new com.android.Coordinates();
    coordObject.Updates(coordinates);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following method public static void SerializeToXMLFile(Object obj,Type type, string fileName) {
I have following method in the c code. void add(int number) { Node node1;
i have the following method in a usercontrol protected override void Render(HtmlTextWriter writer) {
When you have a method such as the following: public synchronized void addOne() {
I have the following method: private <E extends Number> void AddOne(ArrayList<E> al, Double num)
I have the following method: static Random rr = new Random(); static void DoAction(Action
I have following method in my Borland C++ code, static bool UploadBitstream(void) { //Some
I have the following method: -(void)testAPIModule { self.requests = [NSMutableArray array]; NSLog(@making arrays); /*(A)*/
I have following method in wcf webenabled service Public Person AddPerson(Person p); As of
I have the following method in my code: private bool GenerateZipFile(List<FileInfo> filesToArchive, DateTime archiveDate)

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.