https://github.com/dwickern/sbt-classloader-leak-prevention
An sbt plugin to fix java.lang.OutOfMemoryError: Metaspace/PermGen errors during interactive sbt usage
https://github.com/dwickern/sbt-classloader-leak-prevention
leak sbt sbt-plugin scala
Last synced: 8 months ago
JSON representation
An sbt plugin to fix java.lang.OutOfMemoryError: Metaspace/PermGen errors during interactive sbt usage
- Host: GitHub
- URL: https://github.com/dwickern/sbt-classloader-leak-prevention
- Owner: dwickern
- Created: 2017-02-09T23:58:58.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-02-16T00:52:30.000Z (almost 9 years ago)
- Last Synced: 2025-04-23T17:09:53.673Z (8 months ago)
- Topics: leak, sbt, sbt-plugin, scala
- Language: Scala
- Homepage:
- Size: 26.4 KB
- Stars: 14
- Watchers: 4
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# sbt-classloader-leak-prevention
An sbt plugin to fix `java.lang.OutOfMemoryError: Metaspace/PermGen` errors during interactive sbt usage
# Features
1. Hooks into `sbt test` in jvm projects, and `sbt run` in PlayFramework projects
1. Automatically fixes known leaks using [mjiderhamn/classloader-leak-prevention](https://github.com/mjiderhamn/classloader-leak-prevention)
1. Detects and warns if classloader leaks if still occur, and optionally generates a heap dump
# Usage
Add the following line to your `project/plugins.sbt`:
```
addSbtPlugin("com.github.dwickern" % "sbt-classloader-leak-prevention" % "0.4")
```
# Configuration
| Key | Type | Default | Description
| ----------------------------------------------------- | --------------- | ---------- | ------------------------------------------------------------------- |
| ClassLoaderLeakPreventor.enableLeakPrevention | Boolean | true | Whether to use automatic ClassLoader leak prevention
| ClassLoaderLeakPreventor.enableLeakDetection | Boolean | true | Whether to check for a leaking ClassLoader
| ClassLoaderLeakPreventor.leakDetectionAttempts | Int | 5 | Maximum number of leak detection attempts
| ClassLoaderLeakPreventor.leakDetectionInterval | FiniteDuration | 2.seconds | How long to wait between leak detection attempts
| ClassLoaderLeakPreventor.enableLeakDetectionHeapDump | Boolean | false | Whether to create a heap dump when a ClassLoader leak is detected
| ClassLoaderLeakPreventor.stopThreads | Boolean | true | Whether to force threads to stop
| ClassLoaderLeakPreventor.stopTimerThreads | Boolean | true | Whether to force timer threads to stop
| ClassLoaderLeakPreventor.executeShutdownHooks | Boolean | true | Whether to execute shutdown hooks
| ClassLoaderLeakPreventor.startOracleTimeoutThread | Boolean | true | Whether to force the Oracle JDBC timer thread to start
| ClassLoaderLeakPreventor.threadWait | FiniteDuration | 5.seconds | How long to wait for threads to finish before stopping them
| ClassLoaderLeakPreventor.shutdownHookWait | FiniteDuration | 10.seconds | How long to wait for shutdown hooks to finish before stopping them
# Development
To run tests:
sbt scripted
To publish locally:
sbt publishLocal
To publish to maven central (requires authorization):
sbt release