Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically run GC/finalization after each task execution. #1276

Merged
merged 1 commit into from Apr 22, 2014

Conversation

jsuereth
Copy link
Member

Fixes #1223.

  • Add a new key to disable forcing the garbage collector to run
    after each task-executioin
  • Add a new flag to disable forcing the garbage collector to run
    after each task-exeuction
  • Add a hook into EvalauteTask to run System.gc/System.runFinalization
    after each task execution

Review by @eed3si9n

Fixes #1223.

* Add a new key to disable forcing the garbage collector to run
  after each task-executioin
* Add a new flag to disable forcing the garbage collector to run
  after each task-exeuction
* Add a hook into EvalauteTask to run System.gc/System.runFinalization
  after each task execution

Review by @eed3si9n
@@ -198,6 +211,9 @@ object EvaluateTask
val maker: State => Keys.TaskProgress = getSetting(Keys.executeProgress, const(new Keys.TaskProgress(defaultProgress)), extracted, structure)
maker(state).progress
}
// TODO - Should this pull from Global or from the project itself?
private[sbt] def forcegc(extracted: Extracted, structure: BuildStructure): Boolean =
getSetting(Keys.forcegc in Global, EvaluateTaskConfig.defaultForceGarbageCollection, extracted, structure)
Copy link
Member

Choose a reason for hiding this comment

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

Can it be scoped to the root task so it could be overridden at the task level? Not sure if that's useful.

Copy link
Member Author

Choose a reason for hiding this comment

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

No. There can be multiple roots as of sbt 0.13.2 and you're not guaranteed to have a key relating to the task you run.

Also, I don't think it's particularly useful, but a good suggestion :)

@eed3si9n
Copy link
Member

LGTM

eed3si9n added a commit that referenced this pull request Apr 22, 2014
Automatically run GC/finalization after each task execution.
@eed3si9n eed3si9n merged commit 070f164 into 0.13 Apr 22, 2014
@jsuereth jsuereth deleted the wip/run-finalizer-after-tasks branch April 22, 2014 15:34
// Force finalizers to run.
System.runFinalization()
// Force actually cleaning the weak hash maps.
System.gc()

Choose a reason for hiding this comment

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

Just FYI: All of these are advisory and are no-ops on some JVMs.

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.

None yet

3 participants