Skip to content
Snippets Groups Projects
Commit ccb9a136 authored by Karl Ehatäht's avatar Karl Ehatäht Committed by Guilherme Amadio
Browse files

Fix memory leak in GSLMCIntegrator

The ctor of GSLMCIntegrator creates GSLRngWrapper instance on the heap and calls Allocate() member function which in turn allocates memory for GSL random number generator via gsl_rng_alloc(). When GSLMCIntegrator instance goes out of scope, its dtor is invoked which deletes the GSLRngWrapper pointer and thus invokes its dtor as well. However, ~GSLRngWrapper() frees the allocated memory only if fOwn pointer is set to true, which is only set in assigment operator, but not in the Allocate() member function. Therefore, the GSLMCIntegrator is leaking memory. This poses a problem, when doing large number of integrations inside a for loop. The leak was discovered by running valgrind and inspecting the code.
parent ea4d0c59
Branches
Tags
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment