FERNmatrix / Thermo-nuclear-network

1 stars 5 forks source link

Fixed #21 - missing gsl_vector_free() call for 365 isotope bug. #22

Closed jayjaybillings closed 2 years ago

jayjaybillings commented 2 years ago

Signed-off-by: Jay Jay Billings jayjaybillings@gmail.com

jayjaybillings commented 2 years ago

Merged Mike's most recent changes from guidry_debugPlotOutput2.

guidrymwg commented 2 years ago

I ran the 134-isotope nova calculation with my version of the rv2minus correction and the memory usage (17.4%) is the same as before the correction. So if my version of the correction is valid, the missing free was an error but is not the source of large memory usage.

Mike

On Wed, Aug 17, 2022 at 2:10 PM Jay Jay Billings @.***> wrote:

Merged Mike's most recent changes from guidry_debugPlotOutput2.

— Reply to this email directly, view it on GitHub https://github.com/FERNmatrix/Thermo-nuclear-network/pull/22#issuecomment-1218341737, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEWWFHN2SAQ7HTE7STWQQMTVZUTKXANCNFSM562NTRUQ . You are receiving this because your review was requested.Message ID: @.***>

jayjaybillings commented 2 years ago

Your version calls gsl_vector_free(rv2minus) on line 2334 when it is uncommented, which is after the function exits with return 0 or return 2 as shown here:

       rv2minus = gsl_vector_alloc(ISOTOPES);
        gsl_vector_memcpy(rv2minus,rv2);
        gsl_vector_scale(rv2minus,-1);
        kk = gsl_vector_equal(rv1,rv2minus);

        if(kk==0){

            return 0;  // rv1 not equal to rv2 and not equal to -rv2

        } else {

            return 2;  // rv1 equal to -rv2

        }

        //gsl_vector_free(rv2minus);

    }    // End function compareGSLvectors

That won't work. You have to call it before the if statements as I did here because the function has always executed due to it being an if/else statement:

       gsl_vector * rv2minus = gsl_vector_alloc(ISOTOPES);
        gsl_vector_memcpy(rv2minus, rv2);
        gsl_vector_scale(rv2minus, -1);
        kk = gsl_vector_equal(rv1, rv2minus);

        // Free the vector. Better solution would be to globally allocate
        // this and remove the repeated allocation all together.
        gsl_vector_free(rv2minus);

        if(kk==0){

            return 0;  // rv1 not equal to rv2 and not equal to -rv2

        } else {
            return 2;  // rv1 equal to -rv2
        }

    }    // End function compareGSLvectors