Skip to content

Commit

Permalink
Fix memory leak.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
KostyaSha committed Oct 20, 2018
1 parent c8b0584 commit 70251ea
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/org/kohsuke/github/GHRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.WeakHashMap;

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

private String default_branch,language;
private Map<String,GHCommit> commits = new HashMap<String, GHCommit>();
private Map<String,GHCommit> commits = new WeakHashMap<String, GHCommit>();

@SkipFromToString
private GHRepoPermission permissions;
Expand Down

0 comments on commit 70251ea

Please sign in to comment.