Issue 1:
I am trying to build binaries at HEAD of master for mesos. I am following the instructions here: https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/getting-started-guides/mesos.md

When building, gcc fails because it is unable to allocate memory:

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 > threshold ${KUBE_PARALLEL_BUILD_MEMORY}G, building platforms in parallel"; parallel=true;
else
kube::log::status "Multiple platforms requested, but available ${gigs}G < 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" ) &> "/tmp//${platform//\//_}.build" &
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

OS is Ubuntu 14.10 64-bit running on as a VirtualBox VM through vagrant. The VM has access to 2.5gb of memory.

Seems to be similiar to #6730

Issue 2:
If I try to run hack/update-swagger-spec.sh in my vm with less than 2GB of RAM it fails with this error:

+++ [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

I found that this file pkg/ui/data/swagger/datafile.go for some reason need a lot of memory to be builded. (it is a huge file btw with 48528 lines)

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...