Skip to content

Conversation

@dwnusbaum
Copy link
Member

While testing jenkinsci/pipeline-groovy-lib-plugin#199, I ran into cases where MemoryAssert.assertGC(..., false) was passing, but very slowly, because although there were soft references, they were cleared out prior to an OutOfMemoryError occurring, and so we skipped the code that failed when softErr != null.

This PR adjusts the code to fail if softErr != null after existing the initial loop, so that we also fail in this kind of case.

I have not attempted to test this against other callers of this method, so this is just a draft PR.

Testing done

See the new test in jenkinsci/pipeline-groovy-lib-plugin#199.

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

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

OK I think


/**
* Forces GC by causing an OOM and then verifies the given {@link WeakReference} has been garbage collected.
* <p>Beware that failures messages can be misleading and you may need to use heap dumps to diagnose issues.
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
* <p>Beware that failures messages can be misleading and you may need to use heap dumps to diagnose issues.
* <p>Beware that failure messages can be misleading, and you may need to use heap dumps to diagnose issues.

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.

2 participants