Skip to content

Instantly share code, notes, and snippets.

@ebai101
Last active September 22, 2023 00:17
Show Gist options
  • Save ebai101/898beb04523bc2b74a12e2b00113058a to your computer and use it in GitHub Desktop.
Save ebai101/898beb04523bc2b74a12e2b00113058a to your computer and use it in GitHub Desktop.
google-drive-restarter

Google Drive likes to leak memory on macOS, and since the devs don't seem to want to do anything about it I made these two launch agents to periodically restart it so it doesn't tie up a ton of resources.

  • place them both in ~/Library/LaunchAgents
  • disable launch on login in Google Drive Preferences
  • launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/googledrive.keepalive.plist
  • launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/googledrive.killer.plist
  • restart

Use at your own risk, this might mess up your sync somehow. I haven't had any issues personally. Quitting the app from the menu will not restart it, you'll need to launchctl kickstart the keepalive plist or just restart your computer.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
<key>Label</key>
<string>googledrive.keepalive</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/Google Drive.app/Contents/MacOS/Google Drive</string>
</array>
<key>RunAtLoad</key>
<false/>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>googledrive.killer</string>
<key>OnDemand</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>-c</string>
<string>killall Google\ Drive</string>
</array>
<key>StartInterval</key>
<integer>3600</integer>
</dict>
</plist>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment