<p dir="auto">I am trying to build binaries at <code class="notranslate">HEAD</code> of <code class="notranslate">master</code> for <code class="notranslate">mesos</code>. I am following the instructions here: <a href="https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/getting-started-guides/mesos.md">https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/getting-started-guides/mesos.md</a></p>
<p dir="auto">When building, gcc fails because it is unable to allocate memory:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="root@mesos-master-01:~/kubernetes# make
hack/build-go.sh
+++ [0702 05:12:04] Building go targets for linux/amd64:
    cmd/kube-proxy
    cmd/kube-apiserver
    cmd/kube-controller-manager
    cmd/kubelet
    cmd/hyperkube
    cmd/kubernetes
    plugin/cmd/kube-scheduler
    contrib/mesos/cmd/k8sm-scheduler
    contrib/mesos/cmd/k8sm-executor
    contrib/mesos/cmd/k8sm-controller-manager
    contrib/mesos/cmd/km
    cmd/kubectl
    cmd/integration
    cmd/gendocs
    cmd/genman
    cmd/genbashcomp
    cmd/genconversion
    cmd/gendeepcopy
    examples/k8petstore/web-server
    github.com/onsi/ginkgo/ginkgo
    test/e2e/e2e.test
    contrib/mesos/cmd/k8sm-redirfd
# github.com/GoogleCloudPlatform/kubernetes/contrib/mesos/cmd/k8sm-controller-manager
/usr/local/go/pkg/tool/linux_amd64/6l: running gcc failed: Cannot allocate memory
# github.com/GoogleCloudPlatform/kubernetes/contrib/mesos/cmd/km
/usr/local/go/pkg/tool/linux_amd64/6l: running gcc failed: Cannot allocate memory
!!! Error in /root/kubernetes/hack/lib/golang.sh:382
  'go install &quot;${goflags[@]:+${goflags[@]}}&quot; -ldflags &quot;${version_ldflags}&quot; &quot;${nonstatics[@]:+${nonstatics[@]}}&quot;' exited with status 2
Call stack:
  1: /root/kubernetes/hack/lib/golang.sh:382 kube::golang::build_binaries_for_platform(...)
  2: /root/kubernetes/hack/lib/golang.sh:520 kube::golang::build_binaries(...)
  3: hack/build-go.sh:26 main(...)
Exiting with status 1
!!! Error in /root/kubernetes/hack/lib/golang.sh:438
  '( kube::golang::setup_env; local version_ldflags; version_ldflags=$(kube::version::ldflags); local host_platform; host_platform=$(kube::golang::host_platform); local goflags; eval &quot;goflags=(${KUBE_GOFLAGS:-})&quot;; local use_go_build; local -a targets=(); local arg; for arg in &quot;$@&quot;;
do
    if [[ &quot;${arg}&quot; == &quot;--use_go_build&quot; ]]; then
        use_go_build=true;
    else
        if [[ &quot;${arg}&quot; == -* ]]; then
            goflags+=(&quot;${arg}&quot;);
        else
            targets+=(&quot;${arg}&quot;);
        fi;
    fi;
done; if [[ ${#targets[@]} -eq 0 ]]; then
    targets=(&quot;${KUBE_ALL_TARGETS[@]}&quot;);
fi; local -a platforms=(&quot;${KUBE_BUILD_PLATFORMS[@]:+${KUBE_BUILD_PLATFORMS[@]}}&quot;); if [[ ${#platforms[@]} -eq 0 ]]; then
    platforms=(&quot;${host_platform}&quot;);
fi; local binaries; binaries=($(kube::golang::binaries_from_targets &quot;${targets[@]}&quot;)); local parallel=false; if [[ ${#platforms[@]} -gt 1 ]]; then
    local gigs; gigs=$(kube::golang::get_physmem); if [[ ${gigs} -gt ${KUBE_PARALLEL_BUILD_MEMORY} ]]; then
        kube::log::status &quot;Multiple platforms requested and available ${gigs}G &gt; threshold ${KUBE_PARALLEL_BUILD_MEMORY}G, building platforms in parallel&quot;; parallel=true;
    else
        kube::log::status &quot;Multiple platforms requested, but available ${gigs}G &lt; threshold ${KUBE_PARALLEL_BUILD_MEMORY}G, building platforms in serial&quot;; parallel=false;
    fi;
fi; if [[ &quot;${parallel}&quot; == &quot;true&quot; ]]; then
    kube::log::status &quot;Building go targets for ${platforms[@]} in parallel (output will appear in a burst when complete):&quot; &quot;${targets[@]}&quot;; local platform; for platform in &quot;${platforms[@]}&quot;;
    do
        ( kube::golang::set_platform_envs &quot;${platform}&quot;; kube::log::status &quot;${platform}: go build started&quot;; kube::golang::build_binaries_for_platform ${platform} ${use_go_build:-}; kube::log::status &quot;${platform}: go build finished&quot; ) &amp;&gt; &quot;/tmp//${platform//\//_}.build&quot; &amp;
    done; local fails=0; for job in $(jobs -p);
    do
        wait ${job} || let &quot;fails+=1&quot;;
    done; for platform in &quot;${platforms[@]}&quot;;
    do
        cat &quot;/tmp//${platform//\//_}.build&quot;;
    done; exit ${fails};
else
    for platform in &quot;${platforms[@]}&quot;;
    do
        kube::log::status &quot;Building go targets for ${platform}:&quot; &quot;${targets[@]}&quot;; kube::golang::set_platform_envs &quot;${platform}&quot;; kube::golang::build_binaries_for_platform ${platform} ${use_go_build:-};
    done;
fi )' exited with status 1
Call stack:
  1: /root/kubernetes/hack/lib/golang.sh:438 kube::golang::build_binaries(...)
  2: hack/build-go.sh:26 main(...)
Exiting with status 1
Makefile:28: recipe for target 'all' failed
make: *** [all] Error 1"><pre class="notranslate"><code class="notranslate">root@mesos-master-01:~/kubernetes# make
hack/build-go.sh
+++ [0702 05:12:04] Building go targets for linux/amd64:
    cmd/kube-proxy
    cmd/kube-apiserver
    cmd/kube-controller-manager
    cmd/kubelet
    cmd/hyperkube
    cmd/kubernetes
    plugin/cmd/kube-scheduler
    contrib/mesos/cmd/k8sm-scheduler
    contrib/mesos/cmd/k8sm-executor
    contrib/mesos/cmd/k8sm-controller-manager
    contrib/mesos/cmd/km
    cmd/kubectl
    cmd/integration
    cmd/gendocs
    cmd/genman
    cmd/genbashcomp
    cmd/genconversion
    cmd/gendeepcopy
    examples/k8petstore/web-server
    github.com/onsi/ginkgo/ginkgo
    test/e2e/e2e.test
    contrib/mesos/cmd/k8sm-redirfd
# github.com/GoogleCloudPlatform/kubernetes/contrib/mesos/cmd/k8sm-controller-manager
/usr/local/go/pkg/tool/linux_amd64/6l: running gcc failed: Cannot allocate memory
# github.com/GoogleCloudPlatform/kubernetes/contrib/mesos/cmd/km
/usr/local/go/pkg/tool/linux_amd64/6l: running gcc failed: Cannot allocate memory
!!! Error in /root/kubernetes/hack/lib/golang.sh:382
  'go install "${goflags[@]:+${goflags[@]}}" -ldflags "${version_ldflags}" "${nonstatics[@]:+${nonstatics[@]}}"' exited with status 2
Call stack:
  1: /root/kubernetes/hack/lib/golang.sh:382 kube::golang::build_binaries_for_platform(...)
  2: /root/kubernetes/hack/lib/golang.sh:520 kube::golang::build_binaries(...)
  3: hack/build-go.sh:26 main(...)
Exiting with status 1
!!! Error in /root/kubernetes/hack/lib/golang.sh:438
  '( kube::golang::setup_env; local version_ldflags; version_ldflags=$(kube::version::ldflags); local host_platform; host_platform=$(kube::golang::host_platform); local goflags; eval "goflags=(${KUBE_GOFLAGS:-})"; local use_go_build; local -a targets=(); local arg; for arg in "$@";
do
    if [[ "${arg}" == "--use_go_build" ]]; then
        use_go_build=true;
    else
        if [[ "${arg}" == -* ]]; then
            goflags+=("${arg}");
        else
            targets+=("${arg}");
        fi;
    fi;
done; if [[ ${#targets[@]} -eq 0 ]]; then
    targets=("${KUBE_ALL_TARGETS[@]}");
fi; local -a platforms=("${KUBE_BUILD_PLATFORMS[@]:+${KUBE_BUILD_PLATFORMS[@]}}"); if [[ ${#platforms[@]} -eq 0 ]]; then
    platforms=("${host_platform}");
fi; local binaries; binaries=($(kube::golang::binaries_from_targets "${targets[@]}")); local parallel=false; if [[ ${#platforms[@]} -gt 1 ]]; then
    local gigs; gigs=$(kube::golang::get_physmem); if [[ ${gigs} -gt ${KUBE_PARALLEL_BUILD_MEMORY} ]]; then
        kube::log::status "Multiple platforms requested and available ${gigs}G &gt; threshold ${KUBE_PARALLEL_BUILD_MEMORY}G, building platforms in parallel"; parallel=true;
    else
        kube::log::status "Multiple platforms requested, but available ${gigs}G &lt; threshold ${KUBE_PARALLEL_BUILD_MEMORY}G, building platforms in serial"; parallel=false;
    fi;
fi; if [[ "${parallel}" == "true" ]]; then
    kube::log::status "Building go targets for ${platforms[@]} in parallel (output will appear in a burst when complete):" "${targets[@]}"; local platform; for platform in "${platforms[@]}";
    do
        ( kube::golang::set_platform_envs "${platform}"; kube::log::status "${platform}: go build started"; kube::golang::build_binaries_for_platform ${platform} ${use_go_build:-}; kube::log::status "${platform}: go build finished" ) &amp;&gt; "/tmp//${platform//\//_}.build" &amp;
    done; local fails=0; for job in $(jobs -p);
    do
        wait ${job} || let "fails+=1";
    done; for platform in "${platforms[@]}";
    do
        cat "/tmp//${platform//\//_}.build";
    done; exit ${fails};
else
    for platform in "${platforms[@]}";
    do
        kube::log::status "Building go targets for ${platform}:" "${targets[@]}"; kube::golang::set_platform_envs "${platform}"; kube::golang::build_binaries_for_platform ${platform} ${use_go_build:-};
    done;
fi )' exited with status 1
Call stack:
  1: /root/kubernetes/hack/lib/golang.sh:438 kube::golang::build_binaries(...)
  2: hack/build-go.sh:26 main(...)
Exiting with status 1
Makefile:28: recipe for target 'all' failed
make: *** [all] Error 1
</code></pre></div>
<p dir="auto">OS is Ubuntu 14.10 64-bit running on as a VirtualBox VM through vagrant. The VM has access to 2.5gb of memory.</p>
<p dir="auto">Seems to be similiar to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="67813222" data-permission-text="Title is private" data-url="https://github.com/kubernetes/kubernetes/issues/6730" data-hovercard-type="issue" data-hovercard-url="/kubernetes/kubernetes/issues/6730/hovercard" href="https://github.com/kubernetes/kubernetes/issues/6730">#6730</a></p>
<p dir="auto">If I try to run <code class="notranslate">hack/update-swagger-spec.sh</code> in my vm with less than <strong>2GB</strong> of RAM it fails with this error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="+++ [0725 01:58:03] Building apiserver
+++ [0725 01:58:10] Building go targets for linux/amd64:
    cmd/kube-apiserver
go build github.com/GoogleCloudPlatform/kubernetes/pkg/ui/data/swagger: /usr/local/go/pkg/tool/linux_amd64/6g: signal: killed
!!! Error in /home/vagrant/gopath/src/github.com/GoogleCloudPlatform/kubernetes/hack/lib/golang.sh:388
  'CGO_ENABLED=0 go install -installsuffix cgo &quot;${goflags[@]:+${goflags[@]}}&quot; -ldflags &quot;${version_ldflags}&quot; &quot;${statics[@]:+${statics[@]}}&quot;' exited with status 1
Call stack:
  1: /home/vagrant/gopath/src/github.com/GoogleCloudPlatform/kubernetes/hack/lib/golang.sh:388 kube::golang::build_binaries_for_platform(...)
  2: /home/vagrant/gopath/src/github.com/GoogleCloudPlatform/kubernetes/hack/lib/golang.sh:521 kube::golang::build_binaries(...)
  3: /home/vagrant/gopath/src/github.com/GoogleCloudPlatform/kubernetes/hack/build-go.sh:26 main(...)
Exiting with status 1
!!! Error in /home/vagrant/gopath/src/github.com/GoogleCloudPlatform/kubernetes/hack/lib/golang.sh:439
  'kube::golang::build_binaries &quot;$@&quot;' exited with status 1
Call stack:
  1: /home/vagrant/gopath/src/github.com/GoogleCloudPlatform/kubernetes/hack/lib/golang.sh:439 kube::golang::build_binaries(...)
  2: /home/vagrant/gopath/src/github.com/GoogleCloudPlatform/kubernetes/hack/build-go.sh:26 main(...)
Exiting with status 1
!!! Error in hack/update-swagger-spec.sh:40
  '&quot;${KUBE_ROOT}/hack/build-go.sh&quot; cmd/kube-apiserver' exited with status 1
Call stack:
  1: hack/update-swagger-spec.sh:40 main(...)
Exiting with status 1
+++ [0725 01:58:41] Clean up complete"><pre class="notranslate"><code class="notranslate">+++ [0725 01:58:03] Building apiserver
+++ [0725 01:58:10] Building go targets for linux/amd64:
    cmd/kube-apiserver
go build github.com/GoogleCloudPlatform/kubernetes/pkg/ui/data/swagger: /usr/local/go/pkg/tool/linux_amd64/6g: signal: killed
!!! Error in /home/vagrant/gopath/src/github.com/GoogleCloudPlatform/kubernetes/hack/lib/golang.sh:388
  'CGO_ENABLED=0 go install -installsuffix cgo "${goflags[@]:+${goflags[@]}}" -ldflags "${version_ldflags}" "${statics[@]:+${statics[@]}}"' exited with status 1
Call stack:
  1: /home/vagrant/gopath/src/github.com/GoogleCloudPlatform/kubernetes/hack/lib/golang.sh:388 kube::golang::build_binaries_for_platform(...)
  2: /home/vagrant/gopath/src/github.com/GoogleCloudPlatform/kubernetes/hack/lib/golang.sh:521 kube::golang::build_binaries(...)
  3: /home/vagrant/gopath/src/github.com/GoogleCloudPlatform/kubernetes/hack/build-go.sh:26 main(...)
Exiting with status 1
!!! Error in /home/vagrant/gopath/src/github.com/GoogleCloudPlatform/kubernetes/hack/lib/golang.sh:439
  'kube::golang::build_binaries "$@"' exited with status 1
Call stack:
  1: /home/vagrant/gopath/src/github.com/GoogleCloudPlatform/kubernetes/hack/lib/golang.sh:439 kube::golang::build_binaries(...)
  2: /home/vagrant/gopath/src/github.com/GoogleCloudPlatform/kubernetes/hack/build-go.sh:26 main(...)
Exiting with status 1
!!! Error in hack/update-swagger-spec.sh:40
  '"${KUBE_ROOT}/hack/build-go.sh" cmd/kube-apiserver' exited with status 1
Call stack:
  1: hack/update-swagger-spec.sh:40 main(...)
Exiting with status 1
+++ [0725 01:58:41] Clean up complete
</code></pre></div>
<p dir="auto">I found that this file <code class="notranslate">pkg/ui/data/swagger/datafile.go</code> for some reason need a lot of memory to be builded. (it is a huge file btw with 48528 lines)</p>
<p dir="auto">Is there anything we can do for that? I find it very difficult to run a VM in my laptop with more that 2GB which actually means that I can't work...</p>