Skip to content
rtyley edited this page Dec 21, 2014 · 6 revisions

Mobile devices don't have as much memory as desktop computers, and on an Android device the amount of memory available to app processes is relatively low (even a Nexus 7 tablet only makes around 64MB available). Although the underlying JGit library used by Agit does it's best to stream large files and not hold them all in-memory at one time, the way Git stores and transmits files in packfiles can cause memory consumption to behave in unpredictable ways.

For example, see this repo with a large file:

https://github.com/kosborn/p2p-adb/commit/7ca8a626b86068031bfdc545edc4bc521e509008#includes/gesture_hash.txt

Large objects are streamed wherever possible and consequently files of this size often won't cause problems, even on a relatively memory constrained device like an Android. That works so long as the large object is stored as a whole object within the Git packfile. However, if the file is similar to any other file stored anywhere within the repositories history, they can both be stored in delta format - which unfortunately requires a full in-memory representation to decompress - and the Android device blows up with an OutOfMemoryError.

The above commit in the p2p-adb repository is a change to the large file, which will have pushed it into delta representation and made it almost impossible to decompress on a low-memory device.

In general, try to avoid checking large (>5MB) files into source control - if the file can be generated or downloaded from another location, an alternative is to include a script to do just that.

Removing big files from your repo's history

As a complement to Agit, I've also created the BFG Repo-Cleaner, a tool to completely remove bad files from the history of your Git repository (like git-filter-branch, but simpler & faster).

https://rtyley.github.io/bfg-repo-cleaner/

A typical command would be:

$ bfg --strip-blobs-bigger-than 5M  my-repo.git