System hangs* when physical memory use exceeds 90%

I can reliably get Ubuntu MATE 17.04 to come just shy of hanging (e.g. takes 30 second for input to show up in terminal shell) by using up most of my physical memory. That seems to happen when I have ~10 Chrome tabs and Atom open.

The issues seem to coincide with kswapd0 kicking in, but that might be a red herring.

I ran memtest, and all tests passed. My Windows 10 dual boot remains stable at 99%+ memory usage (and it takes a LOT more to get it to that point).

So, I’m trying to do two things:

  1. Figure out why it’s so easy to max out my memory usage on this build vs. Windows vs. previous builds, and
  2. More importantly, keep the system stable when this happens.

Basic system info:

lshw:

H/W path         Device     Class          Description
======================================================
                        system         UX31A (ASUS-NotebookSKU)
/0                          bus            UX31A
/0/0                        memory         64KiB BIOS
/0/8                        memory         512KiB L2 cache
/0/9                        memory         128KiB L1 cache
/0/a                        memory         3MiB L3 cache
/0/b                        memory         4GiB System Memory
/0/b/0                      memory         2GiB SODIMM DDR3 Synchronous 1600 MHz
/0/b/1                      memory         DIMM [empty]
/0/b/2                      memory         2GiB SODIMM DDR3 Synchronous 1600 MHz
/0/b/3                      memory         DIMM [empty]
/0/c                        processor      Intel(R) Core(TM) i5-3317U CPU @ 1.70
/0/100                      bridge         3rd Gen Core processor DRAM Controlle
/0/100/2                    display        3rd Gen Core processor Graphics Contr
/0/100/4                    generic        3rd Gen Core Processor Thermal Subsys
/0/100/14                   bus            7 Series/C210 Series Chipset Family U
/0/100/14/0      usb3       bus            xHCI Host Controller
/0/100/14/1      usb4       bus            xHCI Host Controller
/0/100/16                   communication  7 Series/C216 Chipset Family MEI Cont
/0/100/1a                   bus            7 Series/C216 Chipset Family USB Enha
/0/100/1a/1      usb1       bus            EHCI Host Controller
/0/100/1a/1/1               bus            Integrated Rate Matching Hub
/0/100/1a/1/1/2             generic        USB2.0-CRW
/0/100/1b                   multimedia     7 Series/C216 Chipset Family High Def
/0/100/1c                   bridge         7 Series/C216 Chipset Family PCI Expr
/0/100/1c.1                 bridge         7 Series/C210 Series Chipset Family P
/0/100/1c.1/0    wlp2s0     network        Centrino Advanced-N 6235
/0/100/1d                   bus            7 Series/C216 Chipset Family USB Enha
/0/100/1d/1      usb2       bus            EHCI Host Controller
/0/100/1d/1/1               bus            Integrated Rate Matching Hub
/0/100/1d/1/1/5             multimedia     USB2.0 HD UVC WebCam
/0/100/1d/1/1/6             communication  Bluetooth wireless interface
/0/100/1f                   bridge         HM76 Express Chipset LPC Controller
/0/100/1f.2                 storage        7 Series Chipset Family 6-port SATA C
/0/100/1f.3                 bus            7 Series/C216 Chipset Family SMBus Co
/0/100/1f.6                 generic        7 Series/C210 Series Chipset Family T
/0/1             scsi0      storage        
/0/1/0.0.0       /dev/sda   disk           124GB SanDisk SSD U100
/0/1/0.0.0/1     /dev/sda1  volume         449MiB Windows NTFS volume
/0/1/0.0.0/2     /dev/sda2  volume         99MiB Windows FAT volume
/0/1/0.0.0/3     /dev/sda3  volume         15MiB reserved partition
/0/1/0.0.0/4     /dev/sda4  volume         91GiB Windows NTFS volume
/0/1/0.0.0/5     /dev/sda5  volume         23GiB EXT4 volume

cat /etc/*-release

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=17.04
DISTRIB_CODENAME=zesty
DISTRIB_DESCRIPTION="Ubuntu 17.04"
NAME="Ubuntu"
VERSION="17.04 (Zesty Zapus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 17.04"
VERSION_ID="17.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=zesty
UBUNTU_CODENAME=zesty

Let me know if any other info would be helpful (e.g., I have top logs from a hang event, but they’re super long).

I don’t see any swap partition ? Do you have any swap ? (show output of "# swapon --show ).

If you ran out of ram without any swap, you’re in trouble …

/swapfile file 1.1G 0B -1

Relatively small, but it’s there. When the system slows, top shows all 1.1G available .

Thanks, Bernard.

What is in your /etc/fstab file? Does it show a swap partition down at the end something like this?

# SWAP
UUID=c57e19bd-5f78-4098-8cce-3b3c48707ea7   none   swap   sw   0   0

Here’s the relevant portion of /etc/fstab:

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda5 during installation
UUID=9a10e500-eb7d-48c6-bb6a-08cb2e33ce9c /               ext4    errors=remoun$
# /boot/efi was on /dev/sda2 during installation
UUID=00F1-18E6  /boot/efi       vfat    umask=0077      0       1
/swapfile                                 none            swap    sw           $

@mattgif You might look at the following link to see if creating a separate SWAP partition might help your 17.04 installation -

Good luck Matthew.

May be you could try to start using swap sooner.
try to change swappiness to a higher number just to see if it does help :slight_smile:
as root in a shell : # sysctl vm.swappiness=30

It mean that system will start using swap when less than 30% memory is left unused (70%+ used).

But may be we are on a wrong track since 4 GB should be enough for a lot of tabs and the system.

1 Like

I narrowed down the problem a bit. It seems the system is running out of swap memory before it exhausts physical memory. I would have 0MB of swap available while still having around 200MB of physical memory.

Counter-intuitively, increasing the swappiness, per Bernard’s suggestion, seems to have helped this. With swappiness at 30%, at least 300MB of swap memory remains while <90MB of physical memory remain.

The system seems to be running fairly stably now.

As to why my memory was so taxed: Atom. It’s somehow more efficient than stress at bogging down the system.

Thanks for your help, guys!

1 Like

I guess Atom eat the memory faster than you can swap it if you wait too much (reason the swappiness increase helped).

May be you should talk with the atom developpers to ask if they could make atom less agressive against memory.

Happy it’s solved! Linux Rulez!!

4 Likes