Skip to content

Commit 70251ea

Browse files
committed
Fix memory leak.
While repository object is active and code requests commits they are stored in Map. GHCommit.files contains huge String[]/char[] amount of data. The same could be applied to Milestones.
1 parent c8b0584 commit 70251ea

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/java/org/kohsuke/github/GHRepository.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import java.util.Map;
4949
import java.util.Set;
5050
import java.util.TreeMap;
51+
import java.util.WeakHashMap;
5152

5253
import static java.util.Arrays.*;
5354
import static org.kohsuke.github.Previews.*;
@@ -79,10 +80,10 @@ public class GHRepository extends GHObject {
7980
private boolean _private;
8081
private int forks_count, stargazers_count, watchers_count, size, open_issues_count, subscribers_count;
8182
private String pushed_at;
82-
private Map<Integer,GHMilestone> milestones = new HashMap<Integer, GHMilestone>();
83+
private Map<Integer,GHMilestone> milestones = new WeakHashMap<Integer, GHMilestone>();
8384

8485
private String default_branch,language;
85-
private Map<String,GHCommit> commits = new HashMap<String, GHCommit>();
86+
private Map<String,GHCommit> commits = new WeakHashMap<String, GHCommit>();
8687

8788
@SkipFromToString
8889
private GHRepoPermission permissions;

0 commit comments

Comments
 (0)