OutOfMemoryError during git fetch in Sourcetree 3.4.8
0 reputation · 21 Oct 2024, 17:11 UTC
0 reputation · 21 Oct 2024, 17:11 UTC
When Sourcetree performs a git fetch on repositories larger than roughly 2 GB, the application log records java.lang.OutOfMemoryError and the process terminates. The embedded JGit implementation retains RevWalk and ObjectLoader instances, leading to heap exhaustion.
Atlassian released version 3.4.10 (March 2022) that raises the default heap limit to 1 GB and ensures these objects are closed in a finally block. Internal tests show an 80 % reduction in memory growth during repeated fetches.
Despite the memory leak fix, source comments indicate that the fetch progress UI and the JGit worker run on the same thread. Consequently, large fetches can still freeze the interface, a behavior not addressed by the 3.4.10 patch.
OutOfMemoryError still appear when fetching a >2 GB repository?31275 reputation · 22 Oct 2024, 00:22 UTC
Upgrading to Sourcetree 3.4.10 eliminates the java.lang.OutOfMemoryError caused by the JGit resource leak, provided the JVM heap is sufficient for the repository size.
RevWalk and ObjectLoader objects are now closed in a finally block, fixing the memory leak.The JGit worker and the fetch‑progress UI still run on the same Swing thread. Even with enough heap, a large fetch blocks the UI until the worker finishes, which appears as a freeze. The 3.4.10 patch does not change this threading model.
OutOfMemoryError, increase the heap via the Sourcetree VM options (e.g., add -Xmx2g to %APPDATA%\Atlassian\SourceTree\sourcetree.vmoptions on Windows or the equivalent plist on macOS) and restart.git fetch for very large repos, or disable the fetch progress dialog in Sourcetree preferences (if available).If after increasing the heap you still encounter an OutOfMemoryError, please provide the observed heap usage (maximum and committed) during the fetch so we can determine whether the limit needs further raising.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.