WSL icon indicating copy to clipboard operation
WSL copied to clipboard

How to change memory limitation of Ubuntu sub system.

Open umurgdk opened this issue 10 years ago • 34 comments

I was trying to compile crystal programming language on ubuntu subsystem lately, unfortunately it fails in a way which doesn't makes sense. After some research crystal devs worried about the available ram. Then I thought maybe ubuntu sub system has some memory limitation and bam! there it is. Ubuntu sub systems sees my machine has 1Gb of total ram, instead of 4Gb.

So how can I change/remove this memory limitation?

umurgdk avatar Apr 09 '16 14:04 umurgdk

I also ran into this while trying to compile the ruby runtime through rbenv/ruby-install.

It would be nice if this subsystem had access to the full amount of RAM that Windows has, I'm not sure I could even fit my entire Ruby development environment in memory with only 1GB available.

./tool/runruby.rb:99:in `exec': Cannot allocate memory - ./ruby (Errno::ENOMEM)
        from ./tool/runruby.rb:99:in `<main>'

mchristen avatar Apr 09 '16 17:04 mchristen

No clue how to change it but if you want see how much memory is available use free -m. Currently shows 1006 total with 664 free for me ... nothing running at the moment though oddly when I had redis running free showed the exact same values.

I'm personally having issues with PostgreSQL running due to lack of shared memory (though I'll file a separate bug for that).

Talvish avatar Apr 11 '16 06:04 Talvish

Looks like there's no swap implemented either:

root@localhost:~# dd if=/dev/zero of=/swapfile count=1024 bs=1M
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 0.474613 s, 2.3 GB/s
root@localhost:~# mkswap /swapfile
Setting up swapspace version 1, size = 1048572 KiB
no label, UUID=6e26185d-0408-496c-ad8f-1ee78deb64af
root@localhost:~# swapon /swapfile
swapon: /swapfile: swapon failed: Invalid argument

hut8 avatar Apr 12 '16 21:04 hut8

Thanks for reporting this, I will dig around and see what I can find. We are probably missing a /proc file that those tools are using he query available memory.

benhillis avatar Apr 13 '16 00:04 benhillis

Bump. Can't install ruby as-is

avens19 avatar Apr 13 '16 21:04 avens19

@avens19 you can also just install a package, such as https://launchpad.net/~brightbox/+archive/ubuntu/ruby-ng

hut8 avatar Apr 13 '16 21:04 hut8

I looked into this and this is due to some hardcoded values that we have in procfs (files in /proc). I'd suggest creating a post on our uservoice page that mentions the apps and scenarios that this is currently blocking.

https://wpdev.uservoice.com/forums/266908-command-prompt-console/category/161892-bash

benhillis avatar Apr 14 '16 22:04 benhillis

Hey @benhillis Thanks for the acknowledgement of the issue. I filed a user voice issue on my specific blockers - https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/suggestions/13444257-unable-to-perform-simple-development-tasks-in-bash

Unfortunately, that memory cap makes the bash experience pointless for my workflow. Hopefully we'll see that as a configurable option in the near future. I know that would help the workflow of a number of the devs at my company.

usepowershell avatar Apr 15 '16 19:04 usepowershell

Thanks for filing the user voice. Do you happen to know the specific /proc files that the tools are accessing? Taking an strace and looking just above where the failure is occurring should shed some light. That would greatly help us prioritize this.

benhillis avatar Apr 15 '16 19:04 benhillis

@benhillis Thanks for the response - I grabbed strace logs and posted them to this gist https://gist.github.com/smurawski/25c7d0279a84951a133e0b3f4bdf22a6 . Let me know if I can help in any other way.

usepowershell avatar Apr 18 '16 15:04 usepowershell

@smurawski Thanks, that was very useful. It looks like these two procfs files need to be implemented. I've also added this info to your uservoice page. I'll bring this up with the team and see if we can get somebody working on this ASAP.

/proc/meminfo
/proc/self/status

benhillis avatar Apr 18 '16 16:04 benhillis

Hi @benhillis, another confirmation of the memory limitation. This prevents gcc from building many larger applications. For example 'pip install Image' will fail ass gcc is unable to allocate enough memory. Similarly I have found that creating swap space is not possible. Having a configuration for the available memory in the Linux Subsystem would be incredibly useful. I have added my specific example to @smurawski voice issue.

mondus avatar Apr 19 '16 10:04 mondus

The same issue exists while trying to install some specific versions of ruby with rvm.

ghost avatar Apr 25 '16 06:04 ghost

I'm testing a fix for reporting the actual amount of free memory. I'd like to validate that some of the scenarios in this thread will be fixed by this change, could somebody share with me the command line to install a specific ruby gem that was failing previously? (I'm a total ruby noob)

benhillis avatar Apr 25 '16 21:04 benhillis

I didn't see any gems installations that failed in this thread, it was the programming language itself. With Ruby, most people use some "ruby manager" like rvm, and often rvm will download the ruby source, patch it and compile it. So, if you install rvm and ruby with:

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
\curl -sSL https://get.rvm.io | bash -s stable --ruby=2.3.0

that should cause a failure.

hut8 avatar Apr 25 '16 21:04 hut8

Not a ruby gem but

pip install image

Fails with a memory allocation error from gcc during the build.

On Monday, 25 April 2016, Liam [email protected] wrote:

I didn't see any gems installations that failed in this thread, it was the programming language itself. With Ruby, most people use some "ruby manager" like rvm, and often rvm will download the ruby source, patch it and compile it. So, if you install rvm and ruby with:

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 \curl -sSL https://get.rvm.io | bash -s stable --ruby=2.3.0

that should cause a failure.

— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/Microsoft/BashOnWindows/issues/92#issuecomment-214522420

Dr Paul Richmond (Research Fellow) - University of Sheffield http://www.paulrichmond.staff.shef.ac.uk [email protected]

Department of Computer Science http://www.sheffield.ac.uk/dcs Sheffield NVIDIA CUDA Research Centre http://gpucomputing.sites.sheffield.ac.uk/ Advanced Computing Research Centre http://www.acrc.com

mondus avatar Apr 25 '16 21:04 mondus

@benhillis while I didn't have a specific gem build fail, if you install the chefdk and run chef verify, you'll get an out of memory error.

curl -L https://omnitruck.chef.io/install.sh | sudo bash -s -- -P chefdk
chef verify

usepowershell avatar Apr 25 '16 22:04 usepowershell

Is there a fix for this issue any time soon? I've experienced the problem with ruby, postgres and npm.

ghost avatar Apr 26 '16 04:04 ghost

Unfortunately it looks like rmv is failing due to some missing execve syscall support and not the incorrect memory reporting.

I will try more of the commands in this thread and see if others are actually failing due to the incorrect proc meminfo file.

benhillis avatar Apr 26 '16 14:04 benhillis

I was attempting to install ruby 2.3 from source using ruby-install as a plugin inside of rbenv.

mchristen avatar Apr 26 '16 15:04 mchristen