Skip to content

fix memory leaks and thread issues in BCFitter and descendants - #98

Merged
oschulz merged 10 commits into
bat:masterfrom
fredRos:fitter
Nov 27, 2015
Merged

oschulz merged 10 commits into
bat:masterfrom
fredRos:fitter

Conversation

@fredRos

@fredRos fredRos commented Nov 23, 2015

Copy link
Copy Markdown
Contributor

I managed to make the code much safer and removed a total of 500 lines.
The first commit is just convenience to avoid memory leaks. Check the message of the second commit for an overview of changes. make check passed with multiple threads on root 5.34.25, 6.04.10 and 6.05.02

Frederik Beaujean added 2 commits November 23, 2015 17:20
The major goal was to remove all apparent memory leaks.

Along the way, I found many other things to improve

BCFitter and children
---------------------

* require a TF1 in the constructor and copy it. This way, dozens of
  checks if TF1 exists are obsolete and the code is much shorter. No more
  setting the TF1 later on.
* no more pointer members => copy ctor, copy assignment, swap etc. are
  trivial and autogenerated. The copy now works as expected and all
  members are cleared up to avoid memory leaks
* use BCTrash<TObject> to keep root plot objects alive until the
  BCFitter goes out of scope, then they are properly removed
* use `virtual` keyword where overriding is intended
* remove `CDF` and related code. I put this in years ago and it seems
  nobody ever used this, except we did for a comparison in our paper to
  see that Kolmogorov's test is not as useful as the others.
* remove `ReadErrorBandFromFile`. Seemed to be very specific to an
  ancient use.
* rename some variables `hist1` -> `trials`, `hist2` ->
  `successes`... for readability
* add `Integral` as a common method to `BCFitter`

Examples
--------

* minor updates to follow the new ctor
* replace pointers by values where possible to move away from root-style
  C++. Remaining pointers put into the trash
@oschulz

oschulz commented Nov 25, 2015

Copy link
Copy Markdown
Member

Tests run fine on OS-X but on Linux, tests fail reproducibly at "graphFitterAdvancedExample.C" when using ROOT-5.34.32. With ROOT-6, all seems fine.

Frederik Beaujean added 2 commits November 26, 2015 14:47
* adapt to new BCGraphFitter API
* fix out-of-source build
* remove pointers
@fredRos

fredRos commented Nov 26, 2015

Copy link
Copy Markdown
Contributor Author

I fixed graphFitterAdvancedExample.C for root 5, updated the example/README to resolve #77 and converted it to markdown, and added some more minor improvements and code polishing. We are getting there...

@oschulz

oschulz commented Nov 26, 2015

Copy link
Copy Markdown
Member

Now distcheck fails completely ;-)

[...]
make[2]: Entering directory `[...]/bat/examples'
make[2]: *** No rule to make target `README', needed by `distdir'.  Stop.

Something missing in dist?

@oschulz
oschulz merged commit b5a9fbb into bat:master Nov 27, 2015
oschulz added a commit that referenced this pull request Nov 27, 2015
Fix memory leaks and thread issues in BCFitter and descendants
Comment thread BAT/BCAux.h

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BCTrash might not be an optimal name for this class:

BCTrash.Put(...)

sounds like "delete this", instead of "keep this alive". :-)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BCTrash might not be an optimal name for this class:

BCTrash.Put(...)

sounds like "delete this", instead of "keep this alive". :-)

In fact Dan and I tossed a lot of different names up, this one remained. Think about this way: if you want a file removed without getting it back you do rm file. If you put it into the trash, you know it's still there until somebody empties the trash later. This corresponds pretty well to our use case at hand.

If, however, you can suggest a better name, I'm happy to change it again.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a really good name for it, either. Well, it's an internal class, so we can change it later, if we want to.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants