[Developers] [ADMB Users] The slow destruction of ADMB

John Sibert sibert at hawaii.edu
Mon Jan 2 09:37:21 PST 2012


How many beers will the culprit be required to shout at the developer 
workshop in March?

One of the nice features of svn.

John
On 01/01/2012 08:13 AM, Johnoel Ancheta wrote:
> Hmm, traced to revision 798 on old repository.  Will correct tommorrow.
>
> On 1/1/12 6:17 AM, dave fournier wrote:
>> I was getting strange behaviour (canadian spelling)  from a
>> routine. I traced it to a buggy routine in  ivsort.cpp  which seems 
>> to have
>> replaced my original code.
>>
>>
>>    int *intarray;
>>    intarray = new int[size];
>>    int i;
>>    for(i=0;i<size;i++)
>>    {
>>       intarray[i] = v(lb+i);
>>    }
>>
>>    //  .......
>>
>>    delete intarray;
>>
>> What is wrong with that?
>>
>> Two things. If you allocate memory with new int[size]
>> you need to deallocate it with
>>
>>    delete [] intarray;
>>
>> Second you should not do this anyway. New and delete are really error 
>> prone
>> so you should use an ivector so that the destructor gets called 
>> automatically.
>>
>>
>>    ivector intarray(0,size-1);
>>    int i;
>>    for(i=0;i<size;i++)
>>    {
>>       intarray[i] = v(lb+i);
>>    }
>>
>> Now you get bounds checking in the safe version of the code.
>>
>> Whenever you make a change to the code you should run it through 
>> valgrind.
>> With much more of this all of admb will be buggy and waste ones time 
>> with
>> strange failures.
>>
>>
>>
>>
>> _______________________________________________
>> Users mailing list
>> Users at admb-project.org
>> http://lists.admb-project.org/mailman/listinfo/users
>>
>
> _______________________________________________
> Users mailing list
> Users at admb-project.org
> http://lists.admb-project.org/mailman/listinfo/users
>

-- 
John Sibert
Emeritus Researcher, SOEST
University of Hawaii at Manoa

Visit the ADMB project http://admb-project.org/



More information about the Developers mailing list