Delete Junk Files on macOS
Junk files are unnecessary files produced by the operating system or software. Junk files keep increasing, but our computer disks are limited. So we need to delete junk files regularly. Otherwise, we may not have enough free space to use.
In this post, I will guide you to delete junk files on macOS.
Delete OS and Third-Party Software Leftovers
JetBrains
Remove JetBrains old version leftovers
- Open the JetBrains Toolbox App.
- Navigate to Settings: Click the gear icon in the upper right corner.
- Go to the “Tools” section: Expand the “Tools” section.
- Find “Clean up leftover tool directories”
HomeBrew
1. Clear outdated or unused packages and downloads from Homebrew
Remove stale lock files and outdated downloads for all formulae and casks, and remove old versions of installed formulae:
brew cleanup |
2. Remove unused dependencies
Uninstall formulae that were only installed as a dependency of another formula and are now no longer needed:
brew autoremove |
Delete Software Cache Files
Docker
1. Remove all unused containers, networks, images (both dangling and unused), and optionally, volumes.
docker system prune |
What is does:
- Removes all stopped containers.
- Removes all unused networks.
- Removes all dangling images (images that are not tagged and not referenced by any container).
- Removes all build cache.
2. Remove Docker images on Docker Desktop
Remove Docker images that you no longer need on Docker Desktop.
NVM
The .nvm/.cache
directory is a local cache utilized by Node Version Manager (NVM). NVM is a command-line utility used to manage multiple Node.js versions on a single system.
The .nvm/.cache
directory stores downloaded Node.js installation files and potentially compiled binaries for specific Node.js versions.
To removes the cached Node.js installation files and compiled binaries:
nvm cache clear |
Delete useless files
Java heap dump
A Java heap dump is a snapshot of the Java Virtual Machine (JVM) heap memory at a specific point in time. It contains information about all the objects and classes residing in the heap at the moment the dump is taken. Heap dumps are crucial for diagnosing memory-related issues in Java applications, such as memory leaks, OutOfMemoryError
s, and excessive memory consumption.
Find *.hprof
in the Java home directory
find /Users/<USERNAME>/Library/Java -type f -name '*.hprof' |
Search .hprof
in Finder