JNI problem with Garbage Collector ?

B

bart59

Hi,
I've got a JNI methode, which ceate and lauch a Process in c++ (a
process to make VoIP).
- this methode is returning an int=the pointer to the instance (which
implement this process) so that othet JNI methode can have access to
the main instance.

Under windows, everything works fine, but

Using linux:
I add a memory wathcher on my program to see the memory used by the
application / memory available for the JVM.
The memory used by the application is growing (this is normal at this
point), but when the GC is callled (by the system) the Java
application is frozen (no error message), and I have to kill it. On
the oter side, the Dll is running normally !

My theory is that under Linux, the GC is "feeing" the memory used by
the c++ process , then java is trying to write on it, but have no
access, or somehing like that.

Is there any option to be check this theory: as Java is retunring no
error, but just freezing, it is not very clear to understand.

I tried, using JNI, but removing the Process in it, just calling a
basic operation, and there is no bug.

Is there a special procedure to do on LINUX, for managing the Garbage
Collector with JNI ?

Here is a piece of code :

/***********Java Side******************/
//The JNI def:
public class JNIWrapper {
public JNIWrapper() {

}
// create the h323 Process
public native int create();
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///The class managing the JNI methodes and containing the pointer to
the dll main class
public class CallControlH323 implements CallControl {

int h323StackPtr; //Pointer to the h323stack, needed in the c++ side
JNIWrapper myJNIWrapper;
String options; //option for the CallControl configuration
public CallControlH323(){
myJNIWrapper = new JNIWrapper();
}

public void configure(String options, String codecs) {
h323StackPtr = myJNIWrapper.create();
}
}

/*************************C++ side*****************/

//JNI functions (file JNITerminal.cxx)

#include "JNITerminal.h"
#include <stdio.h>

// Java Global Variables
jobject jobj;
JavaVM *jvm;

/** Create the MainInterface **/
JNIEXPORT jint JNICALL
Java_ca_sess_voicesess_terminal_JNIWrapper_create
(JNIEnv *env, jobject obj)
{
// Make object a Global Reference
jobj = env->NewGlobalRef(obj);
// Get Java VM
env->GetJavaVM(&jvm);

//create and start the main Process
MainInterface * mainInterface;
mainInterface = new MainInterface();

return ( ( jint ) mainInterface );
}

///////////////////////////////////////////////
MainInterface inherite from PProcess (from Pwlib), it is the top
process of the dll application
MainInterface::MainInterface():pProcess("", "", MAJOR_VERSION,
MINOR_VERSION, BUILD_TYPE, BUILD_NUMBER)
#ifdef _MSC_VER
#pragma warning(disable:4355)
#endif
#ifdef _MSC_VER
#pragma warning(default:4355)
#endif
{
ShowOutputs("H323Lib: Create Main Interface");
}

void MainInterface::Main () {}

MainInterface::~MainInterface()
{ }
......
/////////////////////////////////////////////////////////////////////////7

If you have any suggestion, comment, help, don hesitate !!

Thanks for your help

Bart
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

garbage collector 0
Problem with JNI 7
Problem with JNI and Tomcat 6
JNI problem 14
JNI - Garbage collector freeze ? 6
JNI Problems with MINGW32 2
Is my JNI method OK? 3
JNI generic type of jobject 6

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top