Safari (10.0.3) memory leak

hangmemorymemory leaksafariyoutube

Noticed today, Safari occasionally starts eating up memory until it reaches tens of gigabytes of memory used and freezes the whole system.

Safari memory leak

Both cases when this happened, the trigger was starting watching a video on youtube (using the HTML5 player). In Activity Monitor, no particular tab process shows high memory usage (not even the youtube ones), only the main Safari process. Closing tabs one by one does not stop the leak, even when all tabs are closed the main process continues gobbling up the memory. I have no extensions enabled (I disabled AdGuard after the first leak). I sampled the process during the second leak, but I'm not skilled enough to read the output (http://pastebin.com/MTxmEAQ4).

Any ideas how to fix this? I hate going back to Chrome, but this is unacceptable.

Thanks,
O

Best Answer

Time for the Standard Mac App Troubleshooting Steps™

0) Turn off all plugins/extensions

You did this already :)

1) Trash the preferences for the app

You said that you're using stock everything, so this shouldn't result in too much trouble.

Shut down Safari, then open a Finder window, hit cmd-shift-G, and enter ~/Library/Safari. Move the entire contents of this folder somewhere else, either into your trash can or a folder on the desktop.

This will probably solve the problem. Safari is probably choking on something like the history database or some other bit of nonessential stored data.

Start it back up. Problem still exist? Close it down, then:

2) Verify the disk

Sounds trite, but this can cause Weird Stuff to happen. Go to Applications → Utilities → Disk Utility, click on your main hard disk, and select First Aid on the menubar. Let the process run. Did it fix any errors? If not...

3) New user profile

Not quite the nuclear option - but in short, make a new user account and see if Safari behaves the same on that account. Everything should be clean here, and this shouldn't happen.

If it does, something on the system is very, very broken, and you'd need to look into:

4) Recovery install

We've now determined something on the system is trashed. Back up your data and programs, then reboot your machine holding r after the chime, and reinstall Mac OS.