bug-gsl
[Top][All Lists]
Advanced

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

[Bug-gsl] GSL Nonlinear Least-Squares Fitting - Memory Leak


From: Wylie Chan
Subject: [Bug-gsl] GSL Nonlinear Least-Squares Fitting - Memory Leak
Date: Wed, 3 Aug 2005 14:22:52 -0400

Dear GSL Administrator,

I refer to the example code in the GSL reference manual online,
under the section "Nonlinear Least-Squares Fitting" at
http://www.gnu.org/software/gsl/manual/gsl-ref_37.html#SEC476

I tried to replace the 11th line of code in the main method
by replacing the double array with initializer list
with a double pointer to an array initialized using "new", and using 
"delete [ ]" afterwards.

-------------------------------------------------------------------

int
main (void)
{
        ...
        ...
        ...
 

        // Original approach:
        // double x_init[3] = { 1.0, 0.0, 0.0 };

        // My approach: try allocating on heap instead 
        // --> runs fine, but fails in purify (memory leak)
        double * x_init = new double[ 3 ]; 
        x_init[0] = 1.0; 
        x_init[1] = 0.0; 
        x_init[2] = 0.0; 
 
        gsl_vector_view x = gsl_vector_view_array (x_init, p);

        ...
        ...
        ...

        delete [] x_init; 

        return 0;
}

-------------------------------------------------------------------

The result was that the example still ran fine normally,
but in "Purify", memory leaks are detected when in the original example,
no memory leaks were found.

Please advise.

Thank you.


Sincerely,

Wylie Chan

Fixed Income Research
Freddie Mac
1551 Park Run Dr.,
McLean, VA 22102


reply via email to

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