Project

General

Profile

Bug #22223

Task #22198: Address various issues in protodune-sp reconstruction

Possible memory leaks in SpaceChargeProtoDUNE.h

Added by Tingjun Yang 8 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Start date:
03/26/2019
Due date:
% Done:

0%

Estimated time:
Duration:

Description

Valgrind reported many of the following errors in SpaceChargeProtoDUNE.h

==22281== 4 bytes in 1 blocks are definitely lost in loss record 48 of 63,444
==22281==    at 0x4C2A243: operator new(unsigned long) (vg_replace_malloc.c:334)
==22281==    by 0xD6DE25E: TFormula::HandleParamRanges(TString&) (TFormula.cxx:1176)
==22281==    by 0xD6E093C: TFormula::PreProcessFormula(TString&) (TFormula.cxx:1644)
==22281==    by 0xD6D99C1: TFormula::TFormula(char const*, char const*, bool, bool) (TFormula.cxx:403)
==22281==    by 0xD6A6354: TF1::TF1(char const*, char const*, double, double, TF1::EAddToList, bool) (TF1.cxx:566)
==22281==    by 0x26848F2A: spacecharge::SpaceChargeProtoDUNE::SpaceChargeProtoDUNE(fhicl::ParameterSet const&) (SpaceChargeProtoDUNE.h:102)
==22281==    by 0x26601C38: spacecharge::SpaceChargeServiceProtoDUNE::SpaceChargeServiceProtoDUNE(fhicl::ParameterSet const&, art::ActivityRegistry&) (SpaceChargeServiceProtoDUNE_service.cc:27)
==22281==    by 0x26609146: void __gnu_cxx::new_allocator<spacecharge::SpaceChargeServiceProtoDUNE>::construct<spacecharge::SpaceChargeServiceProtoDUNE, fhicl::ParameterSet const&, art::ActivityRegistry&>(spacecharge::SpaceChargeServiceProtoDUNE*, fhicl::ParameterSet const&, art::ActivityRegistry&) (new_allocator.h:136)
==22281==    by 0x26608EEB: void std::allocator_traits<std::allocator<spacecharge::SpaceChargeServiceProtoDUNE> >::construct<spacecharge::SpaceChargeServiceProtoDUNE, fhicl::ParameterSet const&, art::ActivityRegistry&>(std::allocator<spacecharge::SpaceChargeServiceProtoDUNE>&, spacecharge::SpaceChargeServiceProtoDUNE*, fhicl::ParameterSet const&, art::ActivityRegistry&) (alloc_traits.h:475)
==22281==    by 0x26608B75: std::_Sp_counted_ptr_inplace<spacecharge::SpaceChargeServiceProtoDUNE, std::allocator<spacecharge::SpaceChargeServiceProtoDUNE>, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<fhicl::ParameterSet const&, art::ActivityRegistry&>(std::allocator<spacecharge::SpaceChargeServiceProtoDUNE>, fhicl::ParameterSet const&, art::ActivityRegistry&) (shared_ptr_base.h:526)
==22281==    by 0x26608696: std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<spacecharge::SpaceChargeServiceProtoDUNE, std::allocator<spacecharge::SpaceChargeServiceProtoDUNE>, fhicl::ParameterSet const&, art::ActivityRegistry&>(std::_Sp_make_shared_tag, spacecharge::SpaceChargeServiceProtoDUNE*, std::allocator<spacecharge::SpaceChargeServiceProtoDUNE> const&, fhicl::ParameterSet const&, art::ActivityRegistry&) (shared_ptr_base.h:637)
==22281==    by 0x26608087: std::__shared_ptr<spacecharge::SpaceChargeServiceProtoDUNE, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<spacecharge::SpaceChargeServiceProtoDUNE>, fhicl::ParameterSet const&, art::ActivityRegistry&>(std::_Sp_make_shared_tag, std::allocator<spacecharge::SpaceChargeServiceProtoDUNE> const&, fhicl::ParameterSet const&, art::ActivityRegistry&) (shared_ptr_base.h:1295)
==22281== 

It is complaining the following lines in
https://cdcvs.fnal.gov/redmine/projects/dunetpc/repository/revisions/develop/entry/dune/SpaceCharge/SpaceChargeProtoDUNE.h

      TF1 *f1_x = new TF1("f1_x","pol6");
      TF1 *f2_x = new TF1("f2_x","pol6");
      TF1 *f3_x = new TF1("f3_x","pol6");
      TF1 *f4_x = new TF1("f4_x","pol6");
      TF1 *f5_x = new TF1("f5_x","pol6");
      TF1 *fFinal_x = new TF1("fFinal_x","pol4");

      TF1 *f1_y = new TF1("f1_y","pol5");
      TF1 *f2_y = new TF1("f2_y","pol5");
      TF1 *f3_y = new TF1("f3_y","pol5");
      TF1 *f4_y = new TF1("f4_y","pol5");
      TF1 *f5_y = new TF1("f5_y","pol5");
      TF1 *f6_y = new TF1("f6_y","pol5");
      TF1 *fFinal_y = new TF1("fFinal_y","pol5");

      TF1 *f1_z = new TF1("f1_z","pol4");
      TF1 *f2_z = new TF1("f2_z","pol4");
      TF1 *f3_z = new TF1("f3_z","pol4");
      TF1 *f4_z = new TF1("f4_z","pol4");
      TF1 *fFinal_z = new TF1("fFinal_z","pol3");

      TF1 *f1_Ex = new TF1("f1_Ex","pol6");
      TF1 *f2_Ex = new TF1("f2_Ex","pol6");
      TF1 *f3_Ex = new TF1("f3_Ex","pol6");
      TF1 *f4_Ex = new TF1("f4_Ex","pol6");
      TF1 *f5_Ex = new TF1("f5_Ex","pol6");
      TF1 *fFinal_Ex = new TF1("fFinal_Ex","pol4");

      TF1 *f1_Ey = new TF1("f1_Ey","pol5");
      TF1 *f2_Ey = new TF1("f2_Ey","pol5");
      TF1 *f3_Ey = new TF1("f3_Ey","pol5");
      TF1 *f4_Ey = new TF1("f4_Ey","pol5");
      TF1 *f5_Ey = new TF1("f5_Ey","pol5");
      TF1 *f6_Ey = new TF1("f6_Ey","pol5");
      TF1 *fFinal_Ey = new TF1("fFinal_Ey","pol5");

      TF1 *f1_Ez = new TF1("f1_Ez","pol4");
      TF1 *f2_Ez = new TF1("f2_Ez","pol4");
      TF1 *f3_Ez = new TF1("f3_Ez","pol4");
      TF1 *f4_Ez = new TF1("f4_Ez","pol4");
      TF1 *fFinal_Ez = new TF1("fFinal_Ez","pol3");

I talked to Kyle and he suggested changing those pointers to TF1's. Mike and Hannah, do you agree?



Also available in: Atom PDF