Skip to main content

In which file does the KNI provide memory allocation functions?

2 replies [Last post]
Joined: 2006-05-05

When I reading the multitasking guide, I found the following saying:

In native code,when you allocate memory, use KNI field access to store the pointer in the private field. When you free the memory, use KNI field access to store 0 in the field. Using the K Native Interface(KNI) field access avoids race conditions.

Does the KNI provide memory allocation functions? In which file?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2006-09-25

I think this refers to the allocation from native heap, malloc allocation.

KNI itself does not include memory allocation functions.

Joined: 2006-05-05

Hi! danila. Thanks for your answers. May I have your email? In my office i cannot use icq etc. chatting programs. These days, I met a tough problem.

When I put my built midp for wince arm to my smartphone, I got an error.
Firstly, I put the whole midp directory into the directory \Temp.
Secondly, I put the appdb directory and lib directory into the \My Documents\java directory.
Then I run runMidlet.exe. It displayed the logo picture phoneme feature mr3, then it changed to the menu with two options: Install application and manage certification auth.... But in less than one second, the program exit without any indication.
Then I tried to remove the file MIDletSuiteLoader.class and run the runMidlet.exe. This time the logo picture didn't appear.
For this reason I guess the MIDletSuiteLoad class can not find something to load, so the program exited.

I tried many ways to find out what happened. I wrote some code about writing some trace information to a file, I wrote an native method to write what happened in java class to a file. Finally, I stopped at the function primodial_to_current_thread. Since this function is not writen in c language, so I have no way to trace it. Could you please guess what happened to this situation by your experience?