bug-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gsl] Cannot free vector after gsl_multimin_fdfminimizer_x call


From: Frank Reininghaus
Subject: Re: [Bug-gsl] Cannot free vector after gsl_multimin_fdfminimizer_x call
Date: Mon, 18 Apr 2011 11:39:04 +0200

Hi,

2011/4/18 Michael Braun <address@hidden>:
> When I run this code, it prints the current state of the minimizer as 
> expected (as you can see in this output).  The problem comes when trying to 
> free Y.  The error is generated by the gsl_vector_free(Y) call.  I have no 
> idea what I could be doing wrong here.

You are changing the pointer Y in this line:

>     // ASSIGNING CURRENT VALUE TO Y
>     Y = gsl_multimin_fdfminimizer_x(s);

Now it does not point to the address you've allocated in the 'Y =
gsl_vector_alloc(2)' statement, but to some memory which is owned by
the gsl_multimin_fdfminimizer object. This memory is free'd when you
call 'gsl_multimin_fdfminimizer_free (s)', such that any attempt to
free the memory again later on will result in an error.

To fix this, you should copy the values of the vector returned by
'gsl_multimin_fdfminimizer_x(s)' to the vector that 'Y' points to,
rather than changing the pointer itself.

Cheers,
Frank



reply via email to

[Prev in Thread] Current Thread [Next in Thread]