Fatal error: runtime: out of memory

We have a golang project that can successfully run unit tests locally.
But we run the same unit tests on Travis CI, we got follow error:
fatal error: runtime: out of memory

Build #8 - pupillord/TiDB-for-PostgreSQL - Travis CI (travis-ci.com)

I guess there may not be enough memory in the running environment, how can I solve this problem?

Hey @pupil,

It seems like your linter is causing exceeding memory usage. There’s a few things I recommend.
Look into golangci-lint, this is a fast Go linter runner. It runs linters in parallel, uses caching, supports yaml config.

You want to set analysis pass results to nil early to garbage collect them sooner. So in theory adding this to your .travis.yml could be extremely useful:

- script: GOGC=20 golangci-lint run -v --concurrency 1 --deadline 3m # https://github.com/golangci/golangci-lint/issues/337#issuecomment-510136513

Let me know how this works.

Montana Mendy
Travis CI Staff

2 Likes