[Ipopt] Jipopt Java interface

Edson Cordeiro do Valle edsoncv at enq.ufrgs.br
Fri Apr 18 14:10:43 EDT 2008


            Rafael
    That's strange, because a call to HS071.dispose() in the HS071.java 
example leads to:


EXIT: Optimal Solution Found.
*** glibc detected *** double free or corruption (!prev): 0x083c96c8 ***


*** The problem solved!
   
   I'll investigate if it is not a problem with the Ipopt version.
                                                                   Best 
Regards

                                                  Edson C. do Valle
                                                edsoncv at enq.ufrgs.br
                                                   Skype: edson.cv



Rafael de Pelegrini Soares escreveu:
> 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