freeing a memory for double [] #32

tadam opened this Issue Sep 3, 2011 · 3 comments


None yet

2 participants


More than one year ago here was commit that caused memory leaks:

For example, if you use Math::GSL::Fit, it will cause a memory leak.

So I have tried to revert this change. Only QRNG.t test have failed because gsl_qrng_get() returns array of doubles.
With a little changes QRNG works correctly.

I have this commit: tadam/math--gsl@a4ac822
All tests successful.

But maybe here some another reasons for initial commit with commented free()?


I originally commented that code out because I was seeing segfaults in CPANTester reports. I like your solution better. The trade-off is that we are forcing people to wait until DESTROY-time to free these objects, which I don't think is too unreasonable. Can you think of a simple way to check if gsl_qrng_free has been called already?

In any case, if you want to make a pull request, I will merge this.

@leto leto added a commit that closed this issue Sep 6, 2011
@leto Plug a memory leak in QRNG, fixes #31 and fixes #32. Also disable som…
…e Randist tests
@leto leto closed this in 3666814 Sep 6, 2011

Hmm, I already have made similar behavior for Math::GSL::Min and Math::GSL::Roots.
In these modules we can't call *_free() and then make DESTROY too.

Anyway, if we call gsl_qrng_free(obj) we can't use this obj anymore. And if somebody already have the code that calls gsl_qrng_free(), it makes no much sense, because the code that uses Math::GSL without freeing double[], will leak in any case. But if we don't want to break such code we can try to support more intelligent DESTROY. What is your opinion about this?

If somebody wants to force freeing object, he can write undef $qrng;. Furthermore, I believe that in the future we should remove *_free() functions from export (IMHO).


I understand better now. And yes, I was confusing DESTROY time and END time. If you submit a pull request to not export *_free functions, I will merge it.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment