vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

.vscode caching too much data since update

Open ghost opened this issue 7 years ago • 53 comments

I have noticed since the recent update that cpptools seems to be caching a lot of data (~1GB for a small project). This seems to be in an ".vscode/ipch" subdirectory.

download_20190323_132636

ghost avatar Mar 23 '19 02:03 ghost

@bobbrow I guess I wasn't clear in what I was asking. I don't want the cache to be eliminated, I simply want the ability to clear it at some point prior to preparing the zip file. But, if it's being stored outside the workspace, I guess that solves my problem.

natet avatar Jun 26 '19 17:06 natet

Joining this discussion a bit late... I appreciate that there is a proposal to change this behaviour. I think that %LOCALAPPDATA% is the right choice on Windows, whereas %USERPROFILE% is NOT (I don't know why many programs write data there, it's not supposed to be used that way). For Linux, I'd strongly support using $XDG_CACHE_HOME, as for example here we have a setup with home directories on NFS (with disk quotas—it's a setup used by University students) and we regularly have issues with ipch folders causing users to exceed their disk quotas ($XDG_CACHE_HOME is set to use the local hard drive). I don't know what the best practice on MacOS would be.

As to whether put it in a Microsoft folder under %LOCALAPPDATA%, I don't have a preference. Maybe it could be a VSCode folder in %LOCALAPPDATA, that all VS Code components writing cache data should use...

And just to give another reason why I find that solving this issue is important: yesterday I double-clicked a .cpp file I wanted to edit (having .cpp files associated with VS Code), while I was using VS Code to edit a web site (therefore the root of the site was open as workspace). I later noticed a very big .vscode folder on the root of the web site! I'd call this behaviour "user data pollution"...

We also had students compressing their project folders, and handing in ZIP files for assignments what ere several dozens of MB instead of a few kB...

hb9tst avatar Jun 28 '19 08:06 hb9tst

I don't know what the best practice on MacOS would be.

I believe you would ideally use URLsForDirectory:inDomain with NSCachesDirectory and NSUserDomainMask but it might be possible to just use $HOME/Library/Caches. In either case, append the VS Code bundle identifier as a subdirectory name.

pedro-w avatar Jun 28 '19 09:06 pedro-w

@hb9tst I created a new issue to track the $XDG_CACHE_HOME at https://github.com/microsoft/vscode-cpptools/issues/3860

sean-mcmanus avatar Jun 29 '19 00:06 sean-mcmanus

I appreciate how well the maintainers handled this issue. There were a lot of people frustrated about this, but you managed to find a solution that took a good middle ground. Thanks!

kylrth avatar Aug 02 '19 14:08 kylrth

For now, I just simply move the directory to a large drive and symlink it.

cloudhan avatar Oct 12 '19 02:10 cloudhan

What about changing the default maximum cash to a reasonable amount: 100 MB and inform the user if more space is needed? What about purging some of the old cashed data?

tomatac avatar Feb 09 '20 06:02 tomatac

I think that simply respecting the standard locations for cache data in each supported OS is the way to go. I say that as a sysadmin (although I'm also a developer using VS Code), because I have a lot of problems with students getting over disk quota in their homes due to VS Code cached data. Of course, they aren't aware at all of it. They are not professional developers, nor they have an in-depth knowledge of the problem. So if VS Code would ask them "can I put more data?" they would probably just click OK.

hb9tst avatar Feb 09 '20 10:02 hb9tst

@hb9tst We've already switched to using a shared location for the IntelliSense cache data at "standard locations". Is there still an issue with our caching behavior?

sean-mcmanus avatar Feb 10 '20 19:02 sean-mcmanus

Can I safely remove subfolders of vscode-cpptools\ipch? Or should I do it by limiting the cache size?

lostmsu avatar May 07 '20 00:05 lostmsu

@lostmsu Ideally you should set your intelliSenseCacheSize to 0, which should cause it to be removed. If you try to remove it manually, that is "safe", but it might be in-use by a cpptools-srv process, and/or a cpptools-srv process might just recreate it.

sean-mcmanus avatar May 07 '20 00:05 sean-mcmanus

@sean-mcmanus I am talking about individual folders, not the entire cache dir.

lostmsu avatar May 07 '20 00:05 lostmsu

Yeah, you can safely remove subfolders. If the cache is in use and you can't delete it, you can close VS Code and then delete the subfolders. A missing cache will just cause it to be regenerated again if it's needed later.

sean-mcmanus avatar May 07 '20 01:05 sean-mcmanus