cannot allocate memory error - go

I just ported my app over from python so I'm a bit new to Go. It seems I am having a memory issues. getAudioOnlyInfo: fork/exec /usr/local/bin/youtube-dl: cannot allocate memory.
This is run on a ubuntu machine. Via supervisor.
Edit:
setting the sysctl -w vm.swappiness=1 resolve the issue

For anyone else who runs into this problem, it was a related recent issue in the golang issue
For all those affected, temporary workaround on Linux until it is
fixed properly can be one of following:
enable unconditional overcommit: sysctl -w vm.overcommit_memory=1
enable unconditional overcommit: sysctl -w vm.overcommit_memory=1 add swap to your host, with sysctl -w vm.swappiness=1 it will almost
never going to be used, but it participates in calculations where
Linux kernel decides to whether it can afford to satisfy allocation or
not when default overcommit_memory=0 is in use

Related

go run/vet/build/test commands hang after completing. Ignores interrupt signal

Similar to the issue #37033541, my commands do not stop. However, my system does not have unmounted drives; my GOPATH is set to /users/user_name/go:/users/user_name/goCode. Neither changing this path to the installation default, nor restarting the computer, or even starting a shell without my bashrc change the behaviour. While it is running, it does generate a functional executable.
I am running go 1.14.1 installed according to the instructions for macOS Mohave.
This behaviour replicates across other packages in my system. But transferring the code to the Go Playground or another Mac computer does not replicate the behaviour. When I run go build -x ..., the last action is: rm -r $WORK/b001/.
Running a stack trace on the process yields ongoing system calls that I cannot interpret (They do seem varied and would be happy to post some if someone would think them useful).
This did not use to happen, it started a few hours ago. I would appreciate the help of someone in troubleshooting this issue.
The issue was resolved only by putting in a fresh installation of the OS and then reinstalling go 1.14.1.
More here: https://groups.google.com/forum/#!topic/golang-nuts/YxqX9o2YJ4k

How do I install a custom kernel on a google compute engine instance?

I would like to install a custom kernel image on a Google Compute Engine instance. I have an instance running with:
foo#instance-1:/boot/efi$ uname -a
Linux instance-1 4.10.0-22-generic #24-Ubuntu SMP Mon May 22 17:43:20 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
And I've built and installed my kernel image:
sudo dpkg -i linux-image-4.10.0-rc8.10.0-rc8_amd64.deb
It shows up in the grub configuration file, I've set the default grub menu item to correct number, and I've run
sudo update-grub
Yet, when I reboot, I get the same kernel I started with.
Google documentation on this seems to be non-existent. There is one spot that suggests I might have to create the image externally, install the kernel, and import it. However, I will need to do this a lot, so I'd rather just install new kernels the old fashioned way.
Turns out that in Google's stock Ubuntu image, there's a grub config file:
/etc/default/grub.d/50-cloudimg-settings.cfg
that overrides what's in
/etc/default/grub
Editing the first file got everything working.
Before attempting this, I assume you have a fallback option? Some way of falling back to your current state. This is important because it seems you may not have physical access to the system.
Please check what /boot/grub/grub.cfg shows as default kernel. It will be a section beginning with menuentry and under that, an entry starting with linux. If that points to /boot/<default-kernel> then that's what you need to update along with initrd entry so that both kernel image and initramfs point to your custom kernel.
Also, it's possible that boot order of kernel images is alphabetical so newer kernel images (later in alphabetical order) have preference over older ones. In that case if you can change kernel image's file name to be higher than default kernel image, and same for the corresponding initramfs and config files (they will all be similarly named) and then run update-grub that may be quicker way of booting into your custom kernel. You can find those files under /boot/.
What worked for me was going into /boot/ and removing the old images and then running sudo dpkg -i <new_image> and rebooting the system with sudo reboot

Detect virtualization in bash

One of my commands in my bash script will depend on the virtualization of the server (XEN or OpenVZ or KVM ). How can I check which of these is in use in bash?
There's a very useful script called imvirt that handles Xen, OpenVZ, VMware, VirtualBox, KVM, and lots of others. It's available as a package in Debian, or from the imvirt web site.
$ imvirt
Xen PV 4.1
I found a small shell script that is able to detect virtualization and it handles Xen,OpenVZ,KVM,Parallels, Vmware and many more
virt-what
Installation with yum is pretty straight forward
Here is the output on my system
$ virt-what
kvm
If you want to detect host (dom0) for xen, check
[ "$(cat /proc/xen/capabilities)" == "control_d" ]
If you want to detect in VM,
You need to execute cpuid instruction in VM, with original_eax=1.
If the resultant ecx has MSB set ((ecx & 0x80000000) != 0), then you are under VM.
This is assuming that your hypervisor supports viridian interface. Xen does.
cpuid package is easily available for many linux distros. I'm sure windows port would be available too. Else, the code is pretty simple for you to write...

Docker base image running slowly Mac OS X

So I have docker set up on OS X by using boot2docker. I have everything working, however, when I run docker run -i -t base /bin/bash it works, the prompt shows up... but it is EXTREMELY slow. By slow, I mean that if I would type one character, it takes about 30 seconds to a minute for that character to show up on the screen. I checked my Activity Monitor to make sure my system wasn't low on memory but that was not the case. It was showing around 85% of idle memory while this process was running. I was curious to see if anyone else on OS X was experiencing issues like this. Any input would be appreciated.
I've experienced the very same problem and as Julian already stated, it's a known issue. But, there is one post in that issue-thread that worked for me (well, at least an adapted version of it).
./boot2docker stop # stop a currently running deamon-instance
./boot2docker delete # remove the vm
rm -rf boot2docker.iso # in my case I had a (very old) iso-image
At this stage any new attempt to re-initialize the boot2docker-vm failed for me. So I was forced to re-install boot2docker itself (and as it turned out I had a very old version). You can do this via Homebrew or with the new installer (whereas, the solution demonstrated in the docker-docu doesn't work anymore). In any case, don't forget to set the DOCKER_HOST variable correct as explained in the documentation:
export DOCKER_HOST=tcp://127.0.0.1:4243
After re-installing boot2docker the following commands should work again:
./boot2docker init # fetches a brand new vm image and initializes
./boot2docker up # now we're back in business
That did it for me - now the performance is as expected
 docker run -i -t --rm dockerfile/ubuntu /bin/bash
gives me an (almost) instant bash-prompt.

Problem with GCC allocated memory on VPS

I am trying to install a python module on my VPS and am running into the following problem once I try to run the install:
virtual memory exhausted: Cannot allocate memory
error: command 'gcc' failed with exit status 1
I tried a few things that I read online to try to solve this but have yet to have any luck. I spoke with a friend at work, and he said that a common way to get around this on a VPS was to alias GCC with mySQLd since VPSs will typically allow more virtual memory for mySQL.
So, my question is: how does one alias GCC with mySQLd and then switch it back?
For reference, I am running CentOS.
I recently had the same issue while compiling PHP5 on a virtual server. The way I finally solved it was to add more swap space by creating a swap file; see http://www.redhat.com/docs/manuals/linux/RHL-8.0-Manual/custom-guide/s1-swap-adding.html for instructions. You may also need to raise vm.max_map_count by running /sbin/sysctl -w vm.max_map_count=[ENOUGH], where [ENOUGH] is a magic number for which I do not have a good recommendation. However, you can check it first (/sbin/sysctl vm.max_map_count) and base your guess on that.
And please congratulate your co-worker on his creativity! :)

Resources