Atom tried to use 40Gb of RAM + all but 4Gb of disk as swap space


#1

So as some of you may know I love using the Atom text editor, I practically worship it while working with other developers. Today I had a bad experience for some reason (it was running in background - I wasn’t coding at the time - just chatting with friends) it tried to allocate 40GB of RAM then filled the disk with swap except for 4Gb of remaining disk space. I’m not sure exactly what happened however I killed it’s processes to avoid any further damage while I investigated.

My System:
I’m running macOS Sierra 10.12.6 on a Macbook Pro with a 120Gb SSD with 60Gb in use, 8Gb of RAM and a 2.7Ghz Processor. This should give you an idea of the performance impact that was going on.

What I found:

  • I’m not sure whether this is related to Atom or not but a git repository somehow got created in my home directory, maybe I ran a script that uses Git (unlikely but possible, generally when I run scripts I’m in the Downloads or Documents folder), maybe I accidentally ran git init and didn’t realize it (most likely scenario). Maybe something had created it however a large number on unstaged changes (basically everything from the last commit (if one even existed) which had been causing performance issues in Atom for some time. I didn’t even realize it until this evening.
  • However this means Git has been tracking changes in application caches stored in my home directory.
  • This was probably a ticking time-bomb (atom had said this huge number of files open at a time for a while - I ignored thinking it was being buggy or whatever) however finally atom responded to some git check (this may of been going on for weeks, I’m not sure how long) and ended up allocating this insane amount of memory in RAM (40Gb) + all free space - 5Gb (macOS likely blocked it from continuing to allocate or it would of allocated the entire disk).
  • I removed the Git Repository and ran first aid on the system to recover the shock Atom Caused to file system. I’m working on measures that could warn me if a Git repo is made on the home directory root again.

What I learned:
Never, ever, ever run git init in /home/username not even accidentally, there are tons of application caches and other stuff stored in hidden folders they’ll get tracked as unstaged changes, Atom’s behavior is if you are viewing a project folder that’s not a Git repo it’ll recursively go up until it finds one or none (assuming this ends at your home directory but it may be up to the disk root - maybe someone with Python experience here could audit Atom’s behavior on macOS) maybe I hit Atom’s internal limit of the amount of unstashed changes causing tonight’s mini disaster (again only someone with Python experience auditing Atom’s behavior on macOS could determine this). I determined that Atom’s Git Package may have some internal limits with huge amounts of unstaged files.

Will I still use Atom:
Absolutely, as far as my investigation went, I determined my error caused a Git Repository to be made on the home directory tracking cache changes, it caused Atom’s git package to hit an internal limit causing this. I obviously need some safe guards put in place to avoid making this mistake again and I’ll be auditing the software & scripts I run on a regularly basis for their use of Git to look for a relationship on whether they caused it or if it was 100% user error


What are your thoughts on this experience with Atom?


#2

What happened to you is not an uncommon experience. You can search this forum for people complaining about Atom eating up large amounts of memory on Mac for the past version cycle, and in most of those threads, they have an absurd number of files being tracked and the fix is to rm -rf ~/.git. So it’s a common experience, but it doesn’t seem to be universal for Mac users. Not using Mac myself, I can only make wild guesses about why so many people have git repos in their home directories.


#3

The Git repo was user error. If I’m understanding correctly Atom can’t handle absurd amounts of files in a Git repo? Is there a known limit before problems start?


#4

Hi @nsuchy ,

Thank you for the awesome write up. We have had a lot of reports from users about this. Mainly this was caused by users accidentally running git init in the home folder. But it will also happen for any repository with a large number of files being tracked, for example if your .gitignore file is not setup correctly. We merged a PR last night to add a limit to this and instead display a message that the repository is too large or in your home/root folder. You can find the details here https://github.com/atom/github/pull/1153.


#5

I’m really impressed with this. You guys did a addressing the issue. I was kinda worried - Atom is my dream of a text editor, it has literally every tool I could desire in one well designed app. Community packages make it perfect. Many people on freeCodeCamp forums tried to get me to switch saying it uses a lot of resources (I just have high end CPU and lots of RAM to address that - Atom does A LOT of things to make your life easier - of course it’s going to need lots of resources) but I love Atom too much and I’m glad that you guys fixed this. Thanks for being awesome :slight_smile: