Skip to content

Always print ReferenceCounter info for leaks#4455

Open
roystgnr wants to merge 3 commits into
libMesh:develfrom
roystgnr:print_only_leaks
Open

Always print ReferenceCounter info for leaks#4455
roystgnr wants to merge 3 commits into
libMesh:develfrom
roystgnr:print_only_leaks

Conversation

@roystgnr
Copy link
Copy Markdown
Member

This info is kind of trivial (and so tempting to suppress via the command-line option) when there's not a leak, but in the event there is a leak, we shouldn't be hiding any details.

See the discussion in idaholab/moose#32877

roystgnr added 2 commits May 11, 2026 22:05
This info is kind of trivial (and so tempting to suppress via the
command-line option) when there's not a leak, but in the event there is
a leak, we shouldn't be hiding any details.
@roystgnr
Copy link
Copy Markdown
Member Author

If @jwpeterson agrees, I'd even be happy to go as far as defaulting to disable_print_counter_info() when there's no leak (with an optional --enable-refcount-printing argument to override, instead of the current --disable- argument). The reference counter info is occasionally interesting for profiling and it's often interesting for debugging leaks but 99.9% of the time it's just clutter.

@moosebuild
Copy link
Copy Markdown

moosebuild commented May 12, 2026

Job Coverage, step Generate coverage on 78b0900 wanted to post the following:

Coverage

5bfc97 #4455 78b090
Total Total +/- New
Rate 65.50% 65.49% -0.00% 100.00%
Hits 78295 78292 -3 5
Misses 41245 41252 +7 0

Diff coverage report

Full coverage report

This comment will be updated on new commits.

@loganharbour
Copy link
Copy Markdown
Member

Works for me. I think the quiet behavior being the default is a good idea

@jwpeterson
Copy link
Copy Markdown
Member

If @jwpeterson agrees, I'd even be happy to go as far as defaulting to disable_print_counter_info() when there's no leak

I can't remember the details, but I think there was a situation (maybe in MOOSE?) where "Memory leak detected!" was being printed at the end of every simulation, but it either wasn't "real" and/or there was nothing we could actually do about it. So that was why we added the ability to disable the leak message entirely.

I searched for the first instance of disable_print_counter_info() and found 0cc5cec (from 2010) and it refers to "Paul", so maybe it was GRINS-related? Anyway, I'm fine with the update, but I guess we'll need to see if there's more false positives once it's turned on all the time.

Comment thread src/base/libmesh.C Outdated
// Ask the \p ReferenceCounter to print its reference count
// information, if printing is enabled. This allows us to find
// memory leaks.
ReferenceCounter::print_info ();
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.

Should we print this to err instead now that we're only printing in the case of leaks? as the next message is to err too

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That's a really good idea. A big leak on a big parallel run will spew a ton of output now, but that's much better than just getting the error message without any hint of the cause if the leak doesn't happen to trigger on rank 0.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants