What happens to memory used in Fit.Curve when MathNet.Numerics.Optimization.MaximumIterationsException

I have the following C# code to do a Gaussian function curve fitting. I am having out-of-memory issue when MathNet.Numerics.Optimization.MaximumIterationsException is raised.

How does Fit.Curve consume memory as it iterates up to maxIterations = 1000? what happens to those memory when MaximumIterationsException is raised. Does the calling code need to do some kind of garbage collection?

        //Define gaussian function
        var gaussian = new Func<double, double, double, double, double>((amplitude, mean, stddev, x) =>
            amplitude * Math.Exp(-0.5 * Math.Pow((x - mean), 2) / Math.Pow(stddev, 2)));


        var (finalAmplitude, finalMean, finalStdDev) = Fit.Curve(xs, ys, gaussian, initialAmplitude, initialMean, initialStdDev);

invalid question. Fit.Curve does not cause out of memory exception