Most of you may have noticed the WinSxS folder in Windows 11/10/8/7 and been surprised at its size. For those who have not, the folder is situated at C:\Windows\WinSxS and has a whopping size! Mine is almost 5 GB and has around 6000 folders & 25000 files and occupies almost 40% of the Windows folder!
While the size of this WinSxS folder, in XP, is around 25-50 MB; its large size in Windows 11. Windows 10, Windows 8, Windows 7, and Windows Vista, is intriguing to many! Check the image below.
What is WinSxS folder in Windows 11/10
The WinSxS folder stores multiple copies of dll, exe, and other system files to let multiple applications run in Windows without any compatibility problems. If you browse inside, you will see what looks like a lot of duplicate files, each with the same name. These are actually different versions of the same files being stored, as different programs may require different versions.
Winsxs, which stands for ‘Windows Side By Side’, is Windows native assembly cache. Libraries that are being by multiple applications are stored there. This feature was first introduced, in Windows ME and was considered as Microsoft’s solution to the so-called ‘dll hell’ issues that plagued Windows 9x.
The ‘backup’ folder is the largest folder in WinSxS, as the image below shows.

Again, as can be seen in the image below, in the WinSxS folder, the ‘Other’ File types take the bulk of the space. These primarily consist of .imd, .ngr, .csd, .dll, .dll.mui, .exe and such other file types.

In Windows now, there isn’t a ‘dllcache’ folder and nor can you find the ‘i386’ folder, where the system caches (like in XP) all it’s source modules. It is this WinSxS folder that stores the shared components of side-by-side applications. These files can be multiple versions of the same assembly or application. Every side-by-side assembly has a unique identity. One of the attributes of the assembly identity is its version.
“Side-by-side assemblies are used by the operating system as fundamental units of naming, binding, versioning, deployment, and configuration. The Winsxs folder includes all manifests, optional components, and 3rd party Win32 files”, says Microsoft.
But, why so many subfolders and why keep so many different versions of the same dll, exe, or other files?
As mentioned, Windows stores the old dlls and library components in the WinSxS folder. If a newer version of this file is part of the OS, but a particular application requires an older version for running, then the older version from the WinSxS folder will be used, leaving the newer version in its present place for other applications that may require it.
Is it safe to delete WinSxS folder?
You cannot delete this directory or move it elsewhere. Nor is it advisable to delete anything here, as such a step could probably make your applications unworkable or even break your system! If you have many applications installed, you can expect to have a jumbo-sized WinSxS folder. This WinSxs folder cannot reside on any other volume than the system volume. This is because of the NTFS hard links. If you try to move the folder, it may result in Windows updates, service packs, features, etc., not installing correctly.
If you delete components from the WinSxS folder like the manifests or the assemblies, etc., you could be in trouble. Each system would react differently. What may work for one could break another! For instance, if you install a program that requires that particular assembly, which you may have deleted, then that program will just not run! Compressing the folder is also a no-no, as it could cause problems during WindowsUpdates or while installing a Hotfix.
The safest way to clean it is by simply uninstalling applications that you don’t require. However, this, too, is not fool-proof, as many applications still leave behind their files here, since they may be shared between other applications. So the probability of dud unused dll‘s being left behind is quite high.
We would not advise the use of WinSxS cleanup tools like WinSxSLite as you could end up breaking your Windows.
If you are into trying out new software or installing and uninstalling frequently, you may notice that your Winsxs size is indeed large. Windows stores multiple copies of these dll files to allow multiple applications without compatibility problems.
Why does WinSxS get so big?
The WinSxS folder grows large because it stores multiple versions of Windows system files and components, which are necessary for updates and software compatibility. It contains hard links, which make it appear larger than it is. Deleting files from WinSxS can cause issues and might increase disk space usage due to dependency errors.
WinSxS Folder Cleanup in Windows 11/10
Windows introduced a new command-line option for WinSxS folder cleanup: DISM.exe, /AnalyzeComponentStore. Running this command, will analyze the WinSxS folder and tell you whether a Component Store Cleanup is recommended or not. It is present in Windows 11/10, as well.
- In Windows 11/10/8.1/8, open Disk Cleanup Tool and use the Windows Update Cleanup option to clean the WinSxS.
- For Windows 7, Microsoft released an update that added the Windows Update Cleanup option to the Disk Cleanup tool.
- Windows Server users can now also clean up WinSxS in Windows Server with the new Update.
Here are some other options you may consider to free up disk space – some routine and some extreme:
- Run Disk Cleanup tool
- Uninstall unused applications
- Move Page file to another drive
- Disable hibernation
- Use the dedicated dump file option to capture memory dump files on another volume on the system.
- Disable system restore points
- Offload user profile and program file directories to another volume on the system.
Information fromTechNet Blogs: One of the largest changes between previous versions of Windows was a move from an INF described OS to componentization. All of the components in the operating system are found in the WinSxS folder – in fact, we call this location the component store. Each component has a unique name that includes the version, language, and processor architecture it was built for. The WinSxS folder is the only location where the component is found on the system; all other instances of the files you see are “projected” by hard linking from the component store.
Now that you know why the store can grow so large, your next question is probably why we don’t remove the older versions of the components. The short answer to that is reliability. The component store, along with other information on the system, allows us to determine at any given time the best version of a component to the project is. That means that if you uninstall a security update, we can install the next highest version on the system – we no longer have an “out of order uninstall” problem. It also means that if you decide to install an optional feature, we don’t just choose the RTM version of the component, we’ll look to see what the highest available version on the system is.
The only way to safely reduce the size of the WinSxS folder is to reduce the set of possible actions that the system can take – the easiest way to do that is to remove the packages that installed the components in the first place. This can be done by uninstalling superseded versions of packages that are on your system. Service Pack 1 contains a binary called VSP1CLN.EXE, a tool that will make the Service Pack package permanent (not removable) on your system, and remove the RTM versions of all superseded components. This can only be done because by making the Service Pack permanent; we can guarantee that we won’t ever need the RTM versions.
Information from E7 Blogs: “Modularizing” the operating system was an engineering goal in Windows. This was to solve several issues in legacy Windows related to installation, servicing, and reliability. The Windows SxS directory represents the “installation and servicing state” of all system components. But in reality, it doesn’t consume as much disk space as it appears when using the built-in tools (DIR and Explorer) to measure disk space used. The fact that we make it tricky for you to know how much space is consumed in a directory is a fair point! The WinSxS directory also enables offline servicing, and makes Windows and later “safe for imaging”.
There have been several blogs and even some “underground” tools that tell you it’s ok to delete the WinSxS directory, and it’s certainly true that after installation, you can remove it from the system, and it will appear that the system boots and runs fine. But as described above, this is a very bad practice, as you’re removing the ability to reliably service, all operating system components and the ability to update or configure optional components on your system. Windows only supports the WinSxS directory on the physical drive in its originally installed location.
Conclusion
Let the WinSxS folder be as it is!
Learn about the Sysnative folder, Panther folder and Catroot & Catroot2 folders here.
Additional reads:
thanks for article
Good Article. I was fixing to use “mklink /J “c:Windowswinsxs” “d:winsxs”
to save room on my ssd as my winsxs folder shows itself to be 9.39 Gigabytes. After reading this i decided i better buy a Larger SSD. Thanks
and finaly MS gives up, and suplies a cleanup tool
http://blogs.technet.com/b/askpfeplat/archive/2013/10/08/breaking-news-reduce-the-size-of-the-winsxs-directory-and-free-up-disk-space-with-a-new-update-for-windows-7-sp1-clients.aspx
Yes – that has been covered here: https://www.thewindowsclub.com/windows-update-cleanup-disk-cleanup-windows :)
Getting a larger SSD isn’t an option, when running Windows inside Oracle VM VirtualBox for example.
I’d kill for a 4GB SXS folder, mine is ridiculous @ > 20GB. Killing the smaller drive that I have for my OS install.
Use the Windows Update Cleanup option in Disk Cleanup Tool. Details for Windows 7 users here: https://www.thewindowsclub.com/windows-update-cleanup-disk-cleanup-windows
microsoft sucks. for me that folder takes 12 GB!!! And as I have SSD there are no more space at all in it. Microsoft must die!!!
does the rundll32.exe normally on the winsxs folder? thanks
Yes, you may see several versions of rundll32.exe in the winsxs folder.
“Let the WinSxS folder be as it is” I cannot agree with this statement. The winsxs folder is something that should go and the sooner that happens the better and easier it will be. It is the result of a decision that microsoft made back with windows 3.0 and while everything including processor scheduling has moved on since then the situation known as DLL hell has only received a patch job and winsxs was born.
Even looking at your example of rundll I can only find two versions, x86 and amd64, so it doesn’t seem that important in any case. The root of the problem is really microsoft’s visual studio compilers and redistributable dll’s. In the 1990’s memory was scarce and dynamic linking was much preferred to static lib linking. Each application would rather than incorporating library code into the executable link to it at runtime so only one copy is present in memory. But updating shared components often results in previously working programs suddenly no longer working. Ms’s solution to the problem was for the program to specify a compatible version of a DLL and load that thus creating the “side-by-side assemblies.”
It did solve one problem, in a way, but introduced numerous others. First off the memory saving of shared components has been unrealised with multiple versions present. And let’s face it, we have much more memory today so we can afford to use static linking instead as many other vendors tried to force. Also if one version of a DLL is patched it still leaves others behind that could be a security risk so it may be a detriment to security.
The correct approach here is to go with the other solution to DDL hell, namely let executables in a single product share the same DLL’s. Dependencies should in any case be stored with the application and not in system folders or the registry.
Just only about 2 month ago I started with Win7 Pro and that was not voluntarily. I like my new hardware, but the difference between XP and Win7 is a terrible and time consuming issue.
Of course, since then I have also searched for and read a lot about the winsxs storage monster. And although there is already written so much about this subject, I like to add something to that.
One of my hobbyhorses is image backups. I can’t remember how long I use already that type of backup for the system drive. However, it is remarkable that I see that advice very occasionally in all the information and discussions at the internet. In case of a Windows or system drive (fatal) malfunction, it is IMHO the only easy, fast and reliable way of recovery. And in less catastrophic situations, restoring an image backup is still the most reliable method for a ‘roll back’.
So, don’t rely on the Windows Recovery options (I never did) and make image backups. And uninstalling updates I never do too. If there would be a reason for ‘roll back’, I use the reliable way.
Therefore I have some requests or suggestions:
To system builders: split up drives in more partitions.
To software developers: offer always the option for installing at a custom location.
To Microsoft developers: make the default location for e.g. personal data NOT at the system drive. It is not only storage, but they are lost by restoring if you forget to copy them before.
Note. All the other suggestions, remarks and complaints would be too much to write here. :-)
Back to storage and winsxs. It is true that HDD storage is cheap and SSD storage not very expensive anymore. So, for new desktop systems the storage costs don’t count (much), but for older hardware and/or notebooks or tablets it can still be a major issue. But winsxs (and DriverStore) has a considerable effect on the size of the (full) image backup. And there are other (performance) drawbacks, e.g. the time needed for searching the system drive, mounting an image backup or scanning the drive with WinDirStat.
For me, the main reason of annoyance is that the MS developers probably think that they are covering nearly all system problems by storing a lot of old versions and duplicates in that winsxs folder. Well, IMHO it is the wrong way and at the wrong location. It is rather ironically and frustrating that if you use the safe backup procedure, a lot of that data is superfluous and is increasing the backup data that is stored (cheap) elsewhere!
Note. I store backups at a partition of the local HDD and copy that data regularly to an external drive.
An example of the MS stupidity. Mainly for curiosity reasons, I installed some additional system languages (using Win7 Ultimate trial). Such updates install a lot of data and when I tested afterwards the uninstalling, I found that most of that huge increase of data was left behind in the winsxs folder. That conclusion is based on the results of WinDirStat and the sizes of image backups. My description of that residue is ‘superfluous rubbish’.
So, I don’t think that uninstalling old/unused software will cleanup that messy winsxs folder.
Unfortunately, it’s nearly impossible for a user to delete some of that garbage in an easy and safe way. I don’t know yet if e.g. the winsxsBackup folder really contains old data that is not used anymore.
And then the argument that it is necessary to keep all the old versions of DLL’s there. I think that it is very likely that most (decent) software is working properly with the newer versions too.
Well, to discuss is the question if every user should be bothered with a lot of unused data because some users are (maybe occasionally) using a program that needs an old specific DLL version. In that case it would be better that the software developer has made his own DLL (version) and install that at the program location. Btw, much software is still doing that.
Note. I don’t understand that if a system DLL is changed significantly, the name is not changed too.
Another disputable large storage folder is ‘DriverStore’ (FileRepository).
Note. I’m not fully sure if this folder is a repository of only non-active or non-installed drivers.
Win7 is still shipped with and installs a lot of drivers for nearly everything. Maybe that was obviously till e.g. 10 years ago, but in my opinion no longer needed anymore. Of course, the installation DVD should contain all the drivers and other stuff that is necessary for a successful installation at all the possible hardware. But installing all that data at the local system drive??
When I have to install some driver, I nearly always look for the latest version on internet. But before that is possible, the ‘vital’ LAN driver has to be installed. However, that driver was (probably) not included in Win7 and for my ASUS P8H77-V motherboard I have to use the ‘Support CD’.
Note. A good new feature of Win7 is the possibility that the system can search the internet when it needs a driver after installing new hardware. Well, for me that is nearly ‘Plug and Play’ too.
So, once again: why all that stuff at the local system drive?
A final (‘funny’) remark about the ‘Cloud’.
For many years it seems to be normal and it is pushed to use the Cloud for storing nearly everything. But what is Microsoft doing: they put a lot of (even unused or obsolete) data at the local system drive! :-)
Note. At the technet website there is a thread with exactly the same title as this article and at the bottom there is a long explanation with remarks and opinions that I like.
If WinSxS was first introduced in Windows ME, how did they actually implement it in that version of Windows? Windows ME only worked in FAT filesystems, and those didn’t have fancy features such as hard links. So they actually duplicated the files in Windows ME so they took twice the space?!
DISM.exe has no /AnalyzeComponentStore command line option in Windows 8.1
Pls see https://www.thewindowsclub.com/windows-component-store-windows-8-1
Problem is that because present day hard drives have such monstrous capacity along with sky drive options software developers can now hire a cheaper and less experienced line of employees who do not know how to write programs as efficiently as they used to when we had the smaller capacity drives.
And they really don’t care, as they now have oodles of gigabytes or terrabytes to write their inefficient programs on, wasting oodles of space at OUR EXPENSE?
REALLY SUCKS!!!!!!!!!!!!!!!!!!!!!
To the editors of this site,
Noticed you removed my post;
Hey, I only spoke the truth without being offensive.
Sorry if the truth (without being offensive) offended you, but hey it’s America and you also can do as you please even if entails removing truth!!
Which post are you talking about? We have not removed any posts. Sometimes one needs to be patient for the comments to appear.
Sorry Anand, I just noticed the default setting for comments was oldest first.
Upon finding and clicking “newest first”, I saw both my posts.
I owe you a sincere apology.
Good write Chris,
I built my wife’s computer (Win7) and also installed a 120gb SSD (Samsung as I believe they are currently the best). I also bought an extra 120gb SSD and used Samsung’s migration software to clone the installed SSD contents to it. Every once in a while (when I think I need to), I install this fresh cloned SSD, and then using Samsung’s Migration software again the old drive gets reformatted and I clone the newly installed SSD contents to the SSD that I removed for the next possible exchange.
If ever I feel that either of these drives are close to their end life, I’ll just go out and buy another new Samsung 120gb SSD (cost of about $80 to $100) and clone to it. This way I always have a spare EXCELLENT WORKING CLONED ssd.
That’s a heck of a lot cheaper than buying a new computer with OS’s that I dislike like Win 8.
See my reply. It’s actually a legacy issue of programmers trying to save space and memory that has failed on the side of compatibility. We should get rid of redistributable components starting with the Microsoft product family and use more of the available space and memory.
Thanks for the input Prom,
I went to wikipedia and read about legacy systems & issues; for anyone interested here’s a link: http://en.wikipedia.org/wiki/Legacy_system
I do think that Microsoft should separate OS software for the business world and OS software for the home user who prefers to maintain their own computer. As a fairly experienced home user, the thing I liked about W98, Wme, Wxp is that it was always pretty easy for the home user to examine and maintain his own system. I never used Wvista because I heard it “sucked”. I’m sort of getting used to maintaining my W7 system, although Microsoft has made it much more difficult for the home user to do “his own” exploring & maintenance.
Relative to the first sentence in my above paragraph, a lot of home users don’t really use a lot of extra software ( maybe just us older folks? – I don’t know).
As for myself, I use the usual software that is included in the MS OS, a simple graphics program from Irfanview, Office Home & Student 2007 (Initially I had installed Office 2013, but dumped it as they gave me no option not to install their Sky Drive which I did not need or want and believe me uninstalling Office 2013 is not doable (spelling?) unless you download MS tool to do so.
So, in short, I plead with MS to come out with an OS (maybe call it MSeasy) for the home user & some of us older folks who don’t use that much extra software and would prefer to easily explore and maintain his own system without all that space wasting Legacy crap.
That’s just my 2 cents.
It’s simple..use DublicateFilesDeleter…I’ve allready tried
Bad idea. Do not use any duplicate file delete software to delete files from the WinSxS folder.
Good writeout!,
Dism /Online /Cleanup-Image /RestoreHealth
///RestoreHealth: This checks for component store corruption, records the corruption to C:WindowsLogsCBSCBS.log and fixes the corruption using Windows Update or using your Windows installation source. This operation takes approximately 10-15 minutes or more depending on the level of corruption and the speed of your computer.
Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
//Using the /ResetBase switch with the /StartComponentCleanup parameter of DISM.exe on a running version of Windows 8.1 removes all superseded versions of every component in the component store.
To reduce the amount of space used by a Service Pack, use the /SPSuperseded parameter of Dism.exe on a running version of Windows 8.1 to remove any backup components needed for uninstallation of the service pack. A service pack is a collection of cumulative updates for a particular release of Windows.
From an elevated command prompt, type the following:
Dism.exe /online /Cleanup-Image /SPSuperseded
Hello
I was hoping to findout how to run a check on my Win7 x64 Home Premium winsxs folder which seems to be corrupted or missing something. Now I also have a side by side issue, have no start menu (grey), am unable to get online, open any MS Software & have zero restore points. I don’t know where to start. Any suggestions?
Yeah, MS sucks…it’s why Linux took off so, Windows is the commercialism of an OS and that means a divergence from generally accepted sound methodologies and general suckage… look how iOS is now starting to suck! But as a developer of some 25 yrs now, this so-called “dll-hell” wasn’t! And we need to spread accurate information! All DLL’s could be, should be, backward compatible. Older apps would find the same services they expected and only newer apps would call on updated services. It was a fine system until idiots got involved! I mean seriously, MS still doesn’t properly retrieve virtual directory paths but expects them to be at default locations and hard-codes them (Silverlight), Fuck!! MS was the core culprit, THEY started changing dll FILENAMES! But this dll hell concept? Morons on Drugs! It was never a problem, but neither were using INI files for localized app data, but you see how long that lasted relatively! The blind leading the dumb!
WRONG! You can use a compression script!
REM Stopping windows installer and windows module installer services
sc stop msiserver
sc stop TrustedInstaller
sc config msiserver start= disabled
sc config TrustedInstaller start= disabled
REM Backing up the ACL’s for the winSXS folder so if things get broken we can restore them later (this will take a while)
icacls “%WINDIR%WinSxS” /save “%WINDIR%WinSxS.acl” /t
REM Taking ownership of the directory and subfolders
takeown /f “%WINDIR%WinSxS” /r
REM Granting full rights on winSXS to the logged in user
icacls “%WINDIR%WinSxS” /grant “%USERDOMAIN%%USERNAME%”:(F) /t
REM Compressing winSXS files and subfolders ignores in use files
compact /s:”%WINDIR%WinSxS” /c /a /i *
REM Restore ownership to TrustedInstaller service
icacls “%WINDIR%WinSxS” /setowner “NT SERVICETrustedInstaller” /t
REM Restore the ACL’s that we backed up
icacls “%WINDIR%” /restore “%WINDIR%WinSxS.acl”
REM Delete the ACL backup file we created
del “%WINDIR%WinSxS.acl”
REM Re-enable windows installer and windows module installer services
sc config msiserver start= demand
sc config TrustedInstaller start= demand
That’s it! the access control list is restored, and you’re good to go.
MS just fool us all with this tools! My winsxs is > 10GB, this tools only help me release less than 2GB space. This folder is still very huge, > 9GB now after cleanup by this tools.
Thanks for the article. I have an external drive for backup that is close to capacity. When looking at contents, I find a large winsxs folder. No idea how it got there. Is it necessary to have it on this external drive that only contains my backup? I checked my c drive and like you said, winsxs is indeed under c:windows
You may delete the WinSxS folder which is present on your external backup drive.
Okay peoples, calm DOWN!
Winsxs stores every version of every DLL you’ve ever run.
That’s right, that’s what I said. You’re not havin’ a flashback.
See, iIt’s characteristic of MS to repair a bad-design glitch with an ugly kludge patch. My winsxs is 18G!
BUT: look at the files in winsxs subfolders. They’re all, like, 8K.
They’re just pointers to other files, like shortcuts, except the system uses them, not your desktop. The properties dlg box shows the combined size of all the dll files that these things point to because they figured it’s more useful than the size of a bunch of 8K pointers.
If you always peek inside stuff like I like to do, open the DLL file with, like, a hex editor or notepad+. Compilers usually put data at the end of the executable image so it’s all together.Plus, you can have a dynamic string pool or context stack. You’ll see all the function names that are in the real DLL, functions that other programs can call.
Those function names are also in the real DLLs, BTW. I guess they did it that way so the interface’s function names can be retrieved without having to open the (possibly huge) real DLL.
Now, who can tell Miss Terna why they did that?
Anyone?
Beuller?
They did it to save disk space back in an ancient civilization where a 15M file was big. They thought about how much space would be wasted if every prog installed its own copy of the dlls. If I had been there,at the conference table, I would have said, “No, no, Mister Ballmer, your idea is stupid. Users only have, what, 100 apps installed? Redundant DLLs take how much space, compared to leaving a copy of every single obsolete, unused DLL on the user’s disk forever?
Ballmer would have hit his fist on the conference table, stood up, and said, “By GOD, you’re right, Luxie! You just saved our reputation for user-oriented quality software engineering! I’m telling your boss to double your salary!”
And I would have said, “No, no, Mister Ballmer, don’t do that! My reward is just knowing that my excellent work is bringing in lots of Money to Microsoft, so you and the othr managers can can stuff it in your pockets!”
Now, if you’re one of the damned ( Real Smart), you will notice the sleight of hand. 18G of DLLs are still on my disk; they’re just somewhere else. So this gimmick still uses mondo disk space, but it also uses the extra space that the winsxs pointer files take up.
Yeah, you, in the back row! Your hand is up?
“Yes Miss Terna, why don’t they just delete the DLLs at uninstall?”
Good question, Beuller!
They can’t delete any DLLs when you deinstall a program because other programs might use the same version of the same DLL. No one in Redmond thought for the DLLs to keep a count of how many different programs installed it. When an uninstall utility sees the count reach zero, it will delete the unused DLL.
…Well, they COULD have done it that way. Frankly, I’d go with redundant copies. But this is Microsoft software! It’s easier for them just to fill up your HDD with old useless files. It’s their way of saying “fu ck you” to the users. They say that in a rich, splendid variety of ways over there in Redmond!
Plus, they can spend the time it would take to do it right by looking at the girl programmers and touching themselves under their desks. When they see ME walk by, I’ll smile shyly for a moment so they have to go in the men’s room and yank. God only knows what the stall walls look like in there.
Nerds! Yucckh!
Why you always gotta talk about the cool kids who take archery? You’re an icky geek!
You get a funeral if you don’t wise up and call me (Carl Poppa).
Thanks for this info.
But yeah im fucked now with a 36GB WinSxS folder on a 120GB SSD. Srew you microcunt!
And thanks for the links in the comments for the cleanup util, i might need it. :-D
This is typical of Microcrap, their installer .msi files, used my software companies, is also a waster of RAM as it duplicates sometimes more than twice and in hard disk copies itself or parts of itself to different folders, and I have checked and many of the files in WinSxS are duplicated, instead of making .ini files and make smart use of folders they could make it efficient and always working for all software, but no they had to go the cheap and dumb way and screw us all in the butt along with it these Suns of Beaches will eventually pay the consequences, as everything doe, of their own acts and It will be too late for regrets; software titan my a$$!!!
Why should WinSxS directory (almost 8GB now) keep browser files like ‘opera.browser’ and ‘firefox.browser’ ? I uninstalled Opera long back and never installed Firefox!
Windows should garbage clean it’s dependencies, in the same way that JavaScript or other runtime platforms do. Keep a counter of use for each dependency. When the counter reaches 0, it means that nobody is using it anymore, hence delete it automatically. No need for “disk cleanup” or other clonky maintenance procedures from the last century when it’s done properly.
Dependencies should be garbage collected. It’s really simple, a counter has to be maintained somewhere, to keep track of the number of links pointing to a particular dependency. When this number reaches 0 it means that the dependency is not referenced anywhere hence there is no use for it and it can be automatically deleted. This is how it’s done in JavaScript, java, and other garbage collected environments.