Kapt: Support paranoid mode in memory leak searcher
This commit is contained in:
@@ -51,7 +51,7 @@ object MemoryLeakDetector {
|
||||
}
|
||||
}
|
||||
|
||||
fun process(): Set<MemoryLeak> {
|
||||
fun process(isParanoid: Boolean): Set<MemoryLeak> {
|
||||
val memoryLeaks = mutableSetOf<MemoryLeak>()
|
||||
|
||||
synchronized(classLoaderData) {
|
||||
@@ -60,7 +60,7 @@ object MemoryLeakDetector {
|
||||
val classLoader = data.ref.get() ?: continue
|
||||
data.age += 1
|
||||
|
||||
if (data.age >= 5) {
|
||||
if (isParanoid || data.age >= 5) {
|
||||
// Inspect statics just once.
|
||||
// Note the 'data' is not added to 'nextClassLoaderData' used the next time.
|
||||
inspectStatics(classLoader)
|
||||
|
||||
@@ -228,7 +228,8 @@ abstract class AbstractKapt3Extension(
|
||||
if (options.detectMemoryLeaks != DetectMemoryLeaksMode.NONE) {
|
||||
MemoryLeakDetector.add(processors.classLoader)
|
||||
|
||||
val (leakDetectionTime, leaks) = measureTimeMillis { MemoryLeakDetector.process() }
|
||||
val isParanoid = options.detectMemoryLeaks == DetectMemoryLeaksMode.PARANOID
|
||||
val (leakDetectionTime, leaks) = measureTimeMillis { MemoryLeakDetector.process(isParanoid) }
|
||||
logger.info { "Leak detection took $leakDetectionTime ms" }
|
||||
|
||||
for (leak in leaks) {
|
||||
|
||||
Reference in New Issue
Block a user