Sunday, September 13, 2015

Loose thoughts by Bjorn Landfeldt

MAC OS X kernel out of memory problem


Over the past few months i have experienced that my MACBook pro running out of memory and suspending all applications for me to fix the issue. The problem has increased in frequency and recently i had enough and actually started looking into the issue. As of now, I have not isolated the exact problem in the code and let's face it I most probably won't have the time to do so given my work load, but I have managed to get around the problem so the system is now not running out of memory. i am running a 2015 model machine with 16 Gbyte of RAM so it is not an issue of actually having too little memory for the tasks I carry out (email, web, powerpoint, programming, MATLAB, LaTex etc.)

In my case, the symptoms were:

From Activity Monitor

  • kernel_task 11-12 Gbyte RAM 200 % CPU
  • nsurlstoraged Lots of RAM 100-200% CPU


This was the case even without any applications running in some cases, in other cases closing Mail or Safari could solve the problem.

Digging around the web a bit to try to figure out if others have had the same problem, I can see I am not alone but so far I have not found any solid advice on what is going on and how to solve the issue. My own experiments are pointing towards nsurlstoraged as being the culprit, running amok and for some reason causing the kernel to grow in size very rapidly.

I found some advice about deleting the SAFARI cache directory and tried that, but the problem remained. I then started looking more closely at nsurlstoraged and noticed that this process seems to trawl through a whole series of files from various applications. Especially I noticed that it started writing copious amounts of data to disk and even though it accesses a large set of files in the file system it spends a lot of time writing data to:

/Library/Containers/com.apple.mail/Data/Library/Caches/com.apple.mail/fsCachedData


and spending much time in other caches as well.

I reacted by doing two things, first I used Onyx (free tool) http://www.titanium.free.fr to clean out caches. Second, I cleaned the Mail idea database by opening the Terminal and typing in the following command:  sqlite3 ~/Library/Mail/V2/MailData/Envelope\ Index vacuum;

The problem has disappeared since then and I don't know if it will reappear but for now I have no issues with exploding kernel memory.

Also, nsurlstoraged is back to 0.0% CPU usage where it should be. I suspect that there is a bug in the code so that this process starts misbehaving when there is too much data to index and keep track of.

1 comment:

Unknown said...

carpet cleaning sydney, carpet cleaners sydney,
http://www.carpetandtilecleaningsydney.com.au/