{"slug": "du-said-chrome-was-using-67-gb-on-my-mac-apfs-said-2", "title": "Du said Chrome was using 67 GB on my Mac. APFS said 2", "summary": "A developer investigating low disk space on a MacBook Air found that `du` reported a Chrome code-signing clone folder at 67 GB, while APFS's actual on-disk usage was about 2.1 GB. The folder held 48 full copies of Chrome created as APFS clones during updates, which share blocks with the original but are counted at full size by `du`, Finder and most disk-map tools. The developer published a 30-line Swift script using `getattrlist` and the `ATTR_CMNEXT_CLONEID`, `ATTR_CMNEXT_EXT_FLAGS` and `ATTR_CMNEXT_PRIVATESIZE` attributes to count each clone's private bytes and shared blocks once per clone family.", "body_md": "My MacBook Air was down to 18 GB free, so I went hunting. The biggest folder on the whole disk, according to `du`, was this:\n\n```\n/private/var/folders/…/X/com.google.Chrome.code_sign_clone   67G\n```\n\nInside: **48 full copies of Google Chrome**. None of them the version I actually have installed.\n\nThen I measured it the way APFS actually stores it, and the 67 GB turned into about 2. Here's the folder, the trap, and a 30-line Swift script that measures any folder the same way.\n\n*(Written with help from an AI assistant. Every number and command was run on my own Mac.)*\n\n## \n  Check yours (read-only)\n\n```\nls \"$(getconf DARWIN_USER_TEMP_DIR)/../X/com.google.Chrome.code_sign_clone\" | wc -l\ndu -sh \"$(getconf DARWIN_USER_TEMP_DIR)/../X/\"*\n```\n\nMine printed `48` and `67G`.\n\nFrom what I can tell, Chrome makes one of these each time it launches after an update. The running browser keeps a validly signed copy of itself while the new version is swapped in underneath. They're meant to be temporary. On my Mac they weren't: 3 copies of Chrome 154 and 45 of 155.0.8059.40, while `/Applications` has 155.0.8059.80.\n\n## \n  The trap: `du` doesn't understand clones\n\nAPFS can *clone* a file. The clone looks like a full copy to every tool, but it shares blocks with the original until one side changes. Chrome makes its copies as clones.\n\n`du`, Finder's Get Info and most disk-map apps add every clone up at full size. 48 × ~1.4 GB = 67 GB that mostly doesn't exist.\n\nAPFS will tell you the truth, you just have to ask through `getattrlist`:\n\n- \n`ATTR_CMNEXT_CLONEID` : which clone family a file belongs to\n- \n`ATTR_CMNEXT_EXT_FLAGS` : bit 0 means \"may share blocks\"\n- \n`ATTR_CMNEXT_PRIVATESIZE` : bytes that belong only to this file\n\nSo: for each clone, count its private bytes, and count the shared part once per family.\n\n## \n  The script\n\n``` python\nimport Foundation\n\n// Usage: swift realsize.swift <folder>\n// Counts APFS clones once: each clone adds only its private bytes,\n// and the shared blocks are counted once per clone family.\nfunc attrs(_ path: String, _ bits: UInt32, _ n: Int) -> [UInt64]? {\n    var al = attrlist(); al.bitmapcount = u_short(ATTR_BIT_MAP_COUNT); al.forkattr = bits\n    var buf = [UInt8](repeating: 0, count: 4 + 8 * n)\n    return buf.withUnsafeMutableBytes { b in\n        guard getattrlist(path, &al, b.baseAddress, b.count, 0x21) == 0 else { return nil }\n        return (0..<n).map { b.loadUnaligned(fromByteOffset: 4 + 8 * $0, as: UInt64.self) }\n    }\n}\nlet root = CommandLine.arguments[1]\nvar naive: Int64 = 0, real: Int64 = 0, families = Set<UInt64>()\nlet e = FileManager.default.enumerator(atPath: root)!\nwhile let rel = e.nextObject() as? String {\n    let p = root + \"/\" + rel\n    var st = stat(); guard lstat(p, &st) == 0, st.st_mode & S_IFMT == S_IFREG else { continue }\n    let full = Int64(st.st_blocks) * 512; naive += full\n    // ATTR_CMNEXT_CLONEID | ATTR_CMNEXT_EXT_FLAGS; flag 1 = may share blocks\n    if let c = attrs(p, 0x100 | 0x200, 2), c[1] & 1 != 0, let priv = attrs(p, 0x8, 1)?[0] {\n        real += Int64(priv)\n        if families.insert(c[0]).inserted { real += full - Int64(priv) }  // shared part, once\n    } else { real += full }\n}\nlet g = 1_073_741_824.0  // GiB, same unit as du -h\nprint(String(format: \"du-style: %.1fG   on disk: %.1fG\", Double(naive) / g, Double(real) / g))\n```\n\n`0x21` is `FSOPT_ATTR_CMN_EXTENDED | FSOPT_NOFOLLOW`. You need Xcode's command line tools for `swift`.\n\nOn the Chrome folder:\n\n``` bash\n$ swift realsize.swift \"$(getconf DARWIN_USER_TEMP_DIR)/../X/com.google.Chrome.code_sign_clone\"\ndu-style: 67.3G   on disk: 2.1G\n```\n\n**67 GB on paper, about 2 GB on disk.** Still waste (those clones keep old Chrome versions' blocks alive), but a 30× smaller problem.\n\nIt's a simplification: a file's \"shared\" part can be shared with files outside the folder, so treat the result as \"roughly what deleting this folder gives back\". (My app's stricter version credits those blocks to whichever file owns them, and lands on 1.8 GB for the same folder.) The honest final check is always `df -h /` before and after (and empty the Trash).\n\n## \n  Should you delete them?\n\nProbably fine, with two rules: quit Chrome completely first (Cmd-Q), and expect them back after the next update. Open the folder with:\n\n```\nopen \"$(getconf DARWIN_USER_TEMP_DIR)/../X\"\n```\n\n…and drag `com.google.Chrome.code_sign_clone` to the Trash. Expect a GB or two back, not 67.\n\n## \n  Why I care\n\nClones are everywhere now: Finder's Duplicate, pnpm's store, Chrome's copies. Any disk tool that sums file sizes will show you folders bigger than your drive, and you'll delete things expecting space you never get.\n\nI ran into this while building [Tidy Mac](https://tidymac.space/?utm_source=devto&utm_medium=article&utm_campaign=chrome-clones), a Mac cleaner. Full disclosure: it's mine. It counts clones once like the script above, labels what's safe to clear, and moves everything to the Trash first.\n\nHow many copies did your Mac have? Post your `ls | wc -l` in the comments. I'm curious if anyone beats 48.", "url": "https://wpnews.pro/news/du-said-chrome-was-using-67-gb-on-my-mac-apfs-said-2", "canonical_source": "https://dev.to/md_ayanbag_03a42545b17ac/du-said-chrome-was-using-67-gb-on-my-mac-apfs-said-2-heres-a-script-to-tell-the-difference-597e", "published_at": "2026-10-18 04:58:13+00:00", "updated_at": "2026-10-18 06:13:31.641378+00:00", "lang": "en", "topics": ["developer-tools"], "entities": ["Google Chrome", "Apple", "APFS", "MacBook Air", "Swift"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/du-said-chrome-was-using-67-gb-on-my-mac-apfs-said-2", "markdown": "https://wpnews.pro/news/du-said-chrome-was-using-67-gb-on-my-mac-apfs-said-2.md", "text": "https://wpnews.pro/news/du-said-chrome-was-using-67-gb-on-my-mac-apfs-said-2.txt", "jsonld": "https://wpnews.pro/news/du-said-chrome-was-using-67-gb-on-my-mac-apfs-said-2.jsonld"}}