# Fix IDEA crashes in Ubuntu  (22.x)

For at least a year I observe sudden crashes of IntelliJ Idea (with SEGFAULT). After the latest ubuntu update, it appear way too often: sometimes even can't open IDE at all becuase it crash during "indexing" phase.

### Did not help

I tried the most common advises:

* Remove caches by removing `~/.cache/JetBrains/IntelliJIdea2022.3/` folder
    
* Disable embedded chrome (for markdown rendering): `ide.browser.jcef.enabled=false` in idea.properties (Help/Edit custom properties)  
    After all I enabled it back.
    

But it didn't help. Moreover, other apps like chrome and docker start failing too.

### Solution

It appears that the problem was in swap file size (even having 64gb of memory, swap is still used). By default, swap file is 2g in ununtu.

To [enlarge it into 4gb](https://ploi.io/documentation/server/change-swap-size-in-ubuntu):

`swapoff -a`  
`fallocate -l 4G /swapfile`  
`chmod 600 /swapfile`  
`mkswap /swapfile`  
`swapon /swapfile`

Another advice was to [encrease swappiness](https://www.omgubuntu.co.uk/2022/06/ubuntu-22-04-systemd-oom-killing-apps#comment-5884426488) to avoid going anything into swap:

`echo vm.swappiness=100 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p`

And, the last thing is the new `systemd-oomd` ubuntu service watching applications for memory and swap consuption and killing them to prevent kernel out of memory.

You can [see its log](https://askubuntu.com/a/1409074) with: `journalctl -u systemd-oomd`

As I understand, it works sometimes not as well as it was planned, and so, having enough memory, it makes sense to [switch it off](https://askubuntu.com/a/1405588) to avoid redundant checks:

`systemctl is-enabled systemd-oomd`  
`systemctl mask systemd-oomd`

(masking to prevent other services to start it)

I suspect the last step wasn't required, but still did it. Overall, I observe much better system performance. IDEA craches are all gone!
