Cloning repositories with large files fails

Summary

When running a gitlab-ci job that contains a large LFS file, the job fails.

Steps to reproduce

Create a repo and add a large file with LFS and start using GitLab CI.

Actual behavior

The build fails with fatal: Out of memory, realloc failed during checkout.

Expected behavior

The configured build job to run.

Environment description

The issue was reproduced with a shell runner running on a Debian VM with 2 GB RAM. The LFS file is ~5 GB.

Used GitLab Runner version

Version:      10.8.0
Git revision: 079aad9e
Git branch:   
GO version:   go1.8.7
Built:        2018-05-22T03:24:56+00:00
OS/Arch:      linux/amd64

The issue might be solved in a way that also addresses #3143 (closed)