Running out of memory in Android 16’s Linux Terminal? Try this fix

Running out of memory in Android 16’s Linux Terminal? Try this fix

Mishaal Rahman / Android Authority

TL;DR

  • Android 15’s new Linux Terminal app is limited to 4GB of memory, which can be insufficient for developers.
  • A workaround involves increasing the zram size, creating a swap file, and adjusting swappiness to improve memory availability.
  • While not a perfect solution, this method should help reduce crashes due to low memory in the Linux VM.

One of the most exciting new features in the second quarterly release of Android 15 is the Linux Terminal app. This app allows you to run full-fledged Linux applications on Android by booting an instance of the Debian distribution within a virtual machine. This virtual machine shares resources and hardware, such as processing power and storage, with the host Android device. By default, the Linux Terminal app is limited to 4GB of memory, which might be insufficient for demanding development workloads. Fortunately, there’s a simple workaround for this limitation.

Linux VM in Android memory use

Mishaal Rahman / Android Authority

A screenshot showing that only 4GB of memory is available in the Linux VM, even on a Pixel 9 Pro where there’s nearly 10GB of free memory.

Although the Linux Terminal app runs on all Pixel phones with the latest Android 15 stable or Android 16 beta releases, it has a fixed memory allocation regardless of the device’s total RAM—whether 8GB, 12GB, or 16GB. This contrasts with Chromebooks, where the Linux VM can utilize nearly all available memory, reserving only 1GB to ensure Chrome OS continues to operate smoothly. Consequently, Chromebooks can handle significantly more memory-intensive development workloads.

Since a primary motivation for Google developing the Linux Terminal app was to bring more development tools to Android, its 4GB memory cap is disappointing. Although the Terminal app features ‘memory ballooning‘ to dynamically adjust the Linux VM’s memory allocation, this capability only allows its usage to fluctuate between the minimum required for VM operation and the aforementioned 4GB limit. Fortunately, the workaround is simple—though not entirely foolproof—and likely familiar to those acquainted with Linux.

Memory allocated to Linux Terminal in Android

Mishaal Rahman / Android Authority

Snippets from the config VM config file showing that a maximum of 4GB of memory is allocated to the Linux VM

As developer Li Zhao highlighted on his blog, the process involves enlarging the zram size from the default 1GB to 8GB, creating an 8GB swap file on disk, and setting the swappiness to an appropriate value (e.g., 100).

To increase the zram size, edit the zram-generator.conf file in /etc/systemd:

Code

$ cat /etc/systemd/zram-generator.conf
[zram0]
zram-size = 8192
compression-algorithm = zstd

To change the swappiness, edit the sysctl.conf file in /etc:

Code

$ cat /etc/sysctl.conf
....
vm.swappiness=100

To create a new 8GB swap file, run these commands:

Code

$ sudo fallocate -l 8G /swap
$ sudo chmod 600 /swap
$ sudo mkswap /swap
$ sudo swapon /swap
$ sudo swapon -s #update /etc/fstab for defaults mount on boot
$ cat /etc/fstab
...
/swap swap swap defaults 0 0

For those unfamiliar, zram lets you use a portion of RAM as compressed swap space, thereby effectively increasing available memory. The swappiness value, on the other hand, dictates how aggressively the Linux kernel handles memory page swapping. While swapping pages with RAM is faster than using disk storage, this isn’t a foolproof method for significantly boosting memory availability—compression has its limits. Nevertheless, this simple workaround should reduce instances of apps being terminated due to low memory or the Linux Terminal crashing, especially when combined with the additional 8GB of swap space on disk.

Have you experimented with the new Linux Terminal app on your Pixel? If so, what have you done with it so far? Let us know in the comments below!

Got a tip? Talk to us! Email our staff at news@androidauthority.com. You can stay anonymous or get credit for the info, it’s your choice.

This article first appeared on Android Authority

📰 Crime Today News is proudly sponsored by DRYFRUIT & CO – A Brand by eFabby Global LLC

Design & Developed by Yes Mom Hosting

Crime Today News

Crime Today News is Hyderabad’s most trusted source for crime reports, political updates, and investigative journalism. We provide accurate, unbiased, and real-time news to keep you informed.

Related Posts