Give me a clean Mac OS


I bought a MacBook Air specially chose the high configuration version. The hard disk space was 128G (Antique machine in 2011). It was used well in the first 1-2 years. Later, it was found that it was more and more incompetent. In order to make space as much as possible, almost all the photos, videos and PDF documents were moved to the cloud, and tools such as cleanmymac were often used to clean up. However, it was still found that some of the space had been damaged Since there is no better solution, write a tool to clean it up.

Give me a clean Mac OS

The content of the first few sections is a relatively tedious introduction to the technology. Students who are not interested in it can jump directly to the section on the use of tools

App’s favorite directories

There is a big difference between the Mac and windows operating systems. Most apps do not have an installation program. Generally, the download is a DMG file, and then the app is directly dragged toapplication programThe directory is OK, so it gives people the feeling to uninstall, that is to drag the app toa wastepaper basketThen empty it. It would be a big mistake to do so. Even the simplest app will leave more or less memorials in the following directories, which are generally:

  • ~/Library

  • ~/Library/Application Support

  • ~/Library/Application Support/CrashReporter

  • ~/Library/Caches

  • ~/Library/Containers

  • ~/Library/LaunchAgents

  • ~/Library/Preferences

  • ~/Library/PreferencePanes

If a program is passedpkgMode installation, or request administrator permission during the first run. Generally, some commemorations will be left in the following directories:

  • /Library

  • /Library/Application Support

  • /Library/Extensions

  • /Library/LaunchAgents

  • /Library/LaunchDaemons

  • /Library/PreferencePanes

  • /Library/Preferences

The above is just a part of the list. Different apps will install some files in other directories due to their needs. For example, word processing software will install fonts under / library / fonts, and some extension components will be placed under / library / scriptingadditions.

Due to the limited space, I can’t introduce all the contents of the catalogue one by one

~/Library/Application Support

This directory can be said to be the most important file directory for apps. Some apps themselves are not big, but they need a lot of supporting components and content, especially software that uses third-party plug-ins and caching network content, such as mineDashIts size is only about 24MB. However, due to frequent browsing, it caches a lot of network content, making its support directory reach the1.37GB! As you can imagine, if you just throw the app into the wastebasket, you will hardly save any space.
Give me a clean Mac OS


The app settings are saved in this directory. Generally speaking, software with a small size has its own configuration information. Although the files stored here do not take up a lot of space, it is still beneficial to clean them up. For example, some apps can’t work normally, even if they are unloaded and reloaded. Usually, the configuration file is wrong. It will be better to clean up and then reload effect.


This directory is the most important directory for the software downloaded from the app store. Due to Apple’s restrictions, the app store software is located in thesandboxEach software has its own complete space in the sandbox. For app, it thinks it is running in a normal directory system, but it is not. The operating system relocates the read-write position to the sandbox.
When you uninstall the software, it’s just a matter ofLaunchpadClick the cross to delete. I don’t know how much space has disappeared inexplicably. I used to unload Netease cloud music in this way, but later I found that 417mb of space was missing
Give me a clean Mac OS


Random boot mode on MACone ofStudents who are familiar with OS X operating system should immediately think of itlaunchctlThis is the place to store the startup configuration file. Most apps only write startup information here. It’s easier to please God than to send God. To send God, you have to use a third-party tool or manually clean it yourself. In addition, there are some differences between launchagents and launchdaemons. Although they are both started randomly, please see for detailsLaunchAgents VS LaunchDaemons

Overview of this tool

Until now, I still think that if cocoa is used to write this tool, the program will be much smaller. Now the program has 40 + MB compression package. In fact, most of them are the framework libraries of electron and react. The real code is only a few files, and the total size is less than 1m. The reason why I choose to use JavaScript to do this is to verify how react develops a desktop application. Is JavaScript capable of unifying the world?

Give me a clean Mac OS

The biggest concern with JavaScript may be the performance problem. Although the program is not difficult, there are several places where the calculation is relatively intensive. One is the parsing of plist information, and the other is regular expression. I put plist parsing into an external library. Regular expressions still use Google’s V8 engine, which is OK at present.

The program has a lot of I / O, so it needs to frequently count the space occupied by files, find relevant files, and read file information. Although the biggest advantage of JavaScript is asynchronous operation, it doesn’t make sense for the interface to make more responses before the results are counted. Therefore, in some places, I don’t use asynchronous operation. If you feel that the interface is a bit stuck, that’s my original Because it’s not react’s fault:)

I’d like to recommend the apple script that comes with the MAC system. This is the Swiss Army knife on the Mac, which can be compared with the PowerShell on windows. My final cleaning work in this software is actually completed through Applescript. For example, the cleaning work needs to close the target program first. How do you plan to implement the program yourself? Enumerate system processes and kill? You can do it very gracefully with Applescript. For example, you open Safari, open a terminal window at the same time, and then type in the terminal

osascript -e 'quit app "safari"' 

The origin of the name

From the movie “total recall” of the same name, after a virtual experience, Quaid suddenly found that he was not an unknown worker, but a super agent. What was he? Maybe the real self will never be found back, but at least not so muddled now.

I would also like to borrow this meaning to show that even through hard cleaning, it can not be restored to the original state, but at least it will not be so bad.

Use of tools

There seems to be nothing to say about this. I just compared the cleaning effect with cleanmymac. At least, in most cases, I feel good.

Comparison of unloading Baidu cloud

Give me a clean Mac OS

You can clearly see that cleanmymac did not find the application support directory of Baidu cloud. In addition, it only found the login key, but not the startup key and startup file.

Give me a clean Mac OS

Total recall not only found all the contents of cleanmymac, but also found application support, which has a space of 1.14MB. In addition, it also found the startup item and startup file in launchdeamons, and found a ghost

Compare uninstalling apps on the app store

Give me a clean Mac OS

Give me a clean Mac OS

Cleanmymac lists a lot of things that are really frightening. When you look at them carefully, you can see that they are allContainers\com.tencent.xinWeChatThe subdirectories in this directory are also filled with a system temporary directory (the system temporary directory will be empty after the computer restarts). When you uninstall, you just need to delete the sandbox directory and everything will be fine.

Existing deficiencies

  • One kind of software is released in the form of package, which has complicated installation steps, such as Microsoft Office 2016 for Mac. For this kind of software, there are more contents to be analyzed, and it is planned to uninstall and integrate the package after improvement

  • The software interface is very simple, one is not good at playing CSS and HTML layout, the other is the first time to use react, front-end experts can give me some advice?

Reference content

  • “In depth analysis of Mac OS X & IOS operating system” is the best choice for people who want to understand the MAC system, and it is worth having

  • Information Property List Key ReferenceThe most important file in app Info.plist It is necessary for development

  • ElectronIf you’re going to build a desktop app with electron, you have to start here

  • ReactThe official website of react, although my interface is very ugly, that’s because I don’t know how to play CSS yet

  • Total RecallThis