On 16 Sep 2009, at 10:38, ruya wrote:
SType is not a SearchFunctor. It is a template parameter of SearchFunctor. Look, I am not a professional coder or something. I could accept that my code has memory leaks, except that I monitored the memory usage and it is stable and quite small too. I have three other algorithms using the same SearchFunctors and the behavior is as expected and no memory leaks. As for the complication that my code appears to be to you, how would you simplify it? You argued before that you would do it diferently and avoid for sure the segmentation fault.
SearchFunctor(){ memh = MemHandler(); generator1 = base_generator_type(MASTER_SEED+13); uni_dist1 = boost::uniform_real<>(0,1); uniEmp = new GeneratorI(generator1, uni_dist1); generator2 = base_generator_type(MASTER_SEED+17); uni_dist2 = boost::uniform_real<>(0,1); uniRes = new GeneratorI(generator2, uni_dist2); } protected: virtual ~SearchFunctor(){}
Just look at this code fragment: you allocate memory in the constructor using new and never release it using delete