[Ipopt] Jipopt Java interface
Rafael de Pelegrini Soares
rafael at vrtech.com.br
Fri Apr 18 13:37:31 EDT 2008
Dear Edson,
I don't think this is the source of the problem you've experienced,
because the Jipopt object is store in a raw pointer. No smart pointer is
used there (around line 600 of Jipopt.cpp):
/* create the IpoptProblem */
Jipopt* problem=new Jipopt(env, obj_this, n, m, nele_jac, nele_hess,
index_style);
Once no smart pointer is used to store the object a regular 'delete'
should be used to destroy it.
Hope this helps.
Regards.
On Fri, 2008-04-18 at 14:06 -0300, Edson Cordeiro do Valle wrote:
> Hello all
> I took a look at the Java Native Interface and I found the
> following function:
>
> JNIEXPORT void JNICALL Java_org_coinor_Ipopt_FreeIpoptProblem
> (JNIEnv *env,
> jobject obj_this,
> jlong pipopt){
> // cast back our class
> Jipopt *problem = (Jipopt *)pipopt;
>
> if(problem!=NULL){
> delete problem;
> }
> }
>
> I don't think it is necessary since the smartpointers automatically
> cleans the unused references as stated in the documentation:
>
> " As the SmartPtrs go out of scope, the reference count
> will be decremented and the objects will automatically
> be deleted."
>
> The calling to this function from java leads the Java Virtual Machine to
> crash, so I suggest this function removal.
>
> Regards
>
More information about the Ipopt
mailing list