4

The system storage seemed to take you a lot of space so I used this software which gives you a visual depiction of the size of files on your Mac (big files are big squares and so on) and turns out these 4 files in system have randomly inflated, it wasn't like this a few months ago. is it safe to delete these files they're in some folder called dyld. if not then what do I do to clear the system storage because I really need the space rn for some applications.enter image description here

6
  • 3
    This picture lacks the essential information: which folder are you looking at here, where are these dyld stored? Also, if they are within /System they are part of macOS and can't be deleted. – nohillside Apr 22 at 7:18
  • yes it is in system but if I cant delete it then is any particular reason as to why it suddenly inflated in size? – python newbie Apr 22 at 7:29
  • On my Mac running Big Sur, the files are located in /System/Library/dyld/, dyld_shared_cache_arm64e, dyld_shared_cache_x86_64 and dyld_shared_cache_x86_64h are ~2 GB large each, so I understand that you would like to get rid of them, but, as pointed out by @nohillside, they are part of macOS and can't (and most importantly, shouldn't) be deleted. – jaume Apr 22 at 7:30
  • What is the size of the files on your system? – jaume Apr 22 at 7:32
  • @jaume somewhere around 2.0-3.0 GB but they weren't this big a few months ago – python newbie Apr 22 at 9:48
9

Is it safe to delete these 4 files in the folder called dyld (/System/Library/dyld/)?

Short answer

No, in Big Sur it's not safe to delete them (from the screenshot in your question, I see you are on Big Sur).

Long answer

In previous macOS versions (at least in macOS 10.15 Catalina, from first-hand experience), these files were located in /var/db/dyld/ and could be recreated with this command (see for example Trying to force update_dyld_shared_cache but having some errors):

sudo update_dyld_shared_cache -root / -force

but update_dyld_shared_cache is deprecated in Big Sur (running the command has as only output This tool is deprecated.).

Furthermore, the files in /System/Library/dyld/ no longer seem to be cache files in the sense that they store commonly used shared libraries (from man update_dyld_shared_cache):

When loading [an executable file], dyld will first check if is in the share cache, and if it is will use that pre-bound version instead of opening, mapping, and binding the original file. This results in significant performance improvements to launch time.

Instead, in Big Sur, the cache files contain most of the macOS libraries.

Let me expand on this: the contents of /var/db/dyld/ (Catalina and earlier macOS versions) and /System/Library/dyld/ (Big Sur) are essentially the same. They both store pairs of files: a text map file (with a .map extension) and a binary shared cache file (without extension), for example:

dyld_shared_cache_x86_64h.map
dyld_shared_cache_x86_64h

The text map file contains information about the shared cache file, and looks like this:

mapping  EX 1331MB 0x7FFF20000000 -> 0x7FFF73398000
mapping  RW  224MB 0x7FFF80000000 -> 0x7FFF8E0C6000
mapping  RO  432MB 0x7FFFC0000000 -> 0x7FFFDB0E0000


/Library/Apple/System/Library/Accounts/Notification/CloudBookmarksAccountsNotifier.bundle/Contents/MacOS/CloudBookmarksAccountsNotifier
                  __TEXT 0x7FFF20040000 -> 0x7FFF20042000
                  __DATA 0x7FFF81B6B108 -> 0x7FFF81B6B8F0
              __LINKEDIT 0x7FFFC05C0000 -> 0x7FFFD8A4A538

/System/Library/AccessibilityBundles/AXSpeechImplementation.bundle/Versions/A/AXSpeechImplementation
                  __TEXT 0x7FFF20042000 -> 0x7FFF20048000
                  __DATA 0x7FFF81B6B8F0 -> 0x7FFF81B6CF70
              __LINKEDIT 0x7FFFC05C0000 -> 0x7FFFD8A4A538

/System/Library/Accounts/Access/CloudKitAccessPlugin.bundle/Contents/MacOS/CloudKitAccessPlugin
                  __TEXT 0x7FFF20048000 -> 0x7FFF2004C000
                  __DATA 0x7FFF81B6CF70 -> 0x7FFF81B6D840
              __LINKEDIT 0x7FFFC05C0000 -> 0x7FFFD8A4A538
(...)

The format of the map file (which is unchanged in Big Sur) is pretty straighforward:

  • It contains a 3-line header
  • It contains several hundreds of entries, one for every file included in the shared cache file, that specify where relevant sections of the specified shared library can be found in the shared cache file

Prior to Big Sur, all shared libraries listed in the map file (that's 1809 in Catalina) were also located in the file system.

In Big Sur, most are not. In fact, in Big Sur 11.2.3, only 12 out of 1956 of the listed libraries can be found in the file system:

(for file in $(grep / /System/Library/dyld/dyld_shared_cache_x86_64.map); do ls $file; done) 2>&1 | grep "No such file or directory" | wc -l
1944
grep / /System/Library/dyld/dyld_shared_cache_x86_64.map | wc -l
1956

That's most probably the reason why the cache files were moved from /var/db/dyld to a SIP-protected folder, namely /System: to make it clear that you shouldn't mess around with them.

If you delete the shared cache files in /System/Library/dyld/, I'm afraid your system won't be able to boot or run.

Further reading

How to fix an extracted dyld from dyld_shared_cache_x86_64? Stack Exchange/Reverse Engineering question on extracting dylib files from the shared cache (mentions a utility named dyld_shared_cache_util from this open source project: dyld-shared-cache-big-sur)

https://www.exploit-database.net/?id=102279 Information about an exploit on how to get privilege escalation via update_dyld_shared_cache on macOS 10.14 Mojave.

https://blog.lse.epita.fr/2017/03/14/playing-with-mach-os-and-dyld.html#the-shared-cache Overview of the shared cache format on OS X 10.10 Yosemite

https://www.theiphonewiki.com/wiki/Dyld_shared_cache Shared cache differences between iOS and macOS prior to Big Sur

3
  • 1
    Nice contribution! – Darwin OS X Apr 22 at 11:45
  • 1
    thank you very much! this is very informative, guess ill just have to look around for some other big files to delete to free up space them – python newbie Apr 22 at 14:08
  • @pythonnewbie I'm glad I could help, yes, you will have to look elsewhere on the disk to free up space. If you found my answer useful, I'd appreciate it if you marked it as accepted to let other people with a simlar issue know that your question is solved. – jaume Apr 25 at 16:36
-5

These are cached files that are created when your mac starts up, they are created again even if you delete it. as it is part of macos system files, it is recommended that you do not delete it.

1
  • 1
    That might have been true in the past, but in Big Sur that's not the case, see my answer below. – jaume Apr 22 at 11:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .