Skip to content

Commit

Permalink
Complete fixing the daemon leaks (#1206 fixes #1194)
Browse files Browse the repository at this point in the history
  • Loading branch information
nedtwigg authored May 13, 2022
2 parents 21b089f + b9e8325 commit 6ef9878
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 2 additions & 0 deletions plugin-gradle/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `3.27.0`).

## [Unreleased]
### Fixed
* More daemon memory consumption fixes ([#1206](https://github.com/diffplug/spotless/pull/1198) fixes [#1194](https://github.com/diffplug/spotless/issues/1194))

## [6.6.0] - 2022-05-10
### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,10 @@ static class LiveCacheKeyImpl<T> implements LiveCache<T>, Serializable {

@Override
public void set(T value) {
if (value instanceof LazyForwardingEquality) {
// whenever we cache an instance of LazyForwardingEquality, we want to make sure that we give it
// a chance to null-out its initialization lambda (see https://github.com/diffplug/spotless/issues/1194#issuecomment-1120744842)
LazyForwardingEquality.unlazy((LazyForwardingEquality<?>) value);
}

// whenever we cache an instance of LazyForwardingEquality, we want to make sure that we give it
// a chance to null-out its initialization lambda (see https://github.com/diffplug/spotless/issues/1194#issuecomment-1120744842)
LazyForwardingEquality.unlazy(value);
daemonState.put(internalKey, value);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021 DiffPlug
* Copyright 2021-2022 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,6 +21,8 @@
import org.gradle.api.Action;
import org.gradle.api.Project;

import com.diffplug.spotless.LazyForwardingEquality;

public class SpotlessExtensionPredeclare extends SpotlessExtension {
private final SortedMap<String, FormatExtension> toSetup = new TreeMap<>();

Expand All @@ -33,6 +35,8 @@ public SpotlessExtensionPredeclare(Project project, GradleProvisioner.Policy pol
lazyAction.execute(formatExtension);
}
getRegisterDependenciesTask().steps.addAll(formatExtension.steps);
// needed to fix Deemon memory leaks (#1194), but this line came from https://github.com/diffplug/spotless/pull/1206
LazyForwardingEquality.unlazy(getRegisterDependenciesTask().steps);
});
});
}
Expand Down

0 comments on commit 6ef9878

Please sign in to comment.