事件还原:电脑使用IntelliJ IDEA运行java项目(其实Eclipse也有类似的情况)时,原本C盘还有接近10G的空间(是我好不容易清出来的10G空间),跑了一段时间后居然提示C盘空间不足,这真是无力吐槽了,现在的工具真的是把内存、硬盘、CPU不当回事了。
接下来让我们看看如何解决这个问题:
1、首先找到配置在哪应该怎么配?
通过资料找到IDEA,在安装目录的bin文件下有一个idea.properties,里面配置了IDEA的各种参数,包括运行缓存目录等,打开bin文件侠找到文件:
打开文件,找到相关配置,发现有以下几个关于目录的配置,当前配置未启用注释的内容实绩就是默认配置,通过配置发现最终的源头就是${user.home}这个变量:
接下来让我们看一下${user.home}配的是什么?我们可以通过在CMD命令窗口中输入:java -XshowSettings:All -version 来查看:
C:\Users\UserName>java -XshowSettings:All -version VM settings: Max. Heap Size (Estimated): 3.93G Using VM: OpenJDK 64-Bit Server VM Property settings: awt.toolkit = sun.awt.windows.WToolkit file.encoding = GBK file.separator = \ java.awt.graphicsenv = sun.awt.Win32GraphicsEnvironment java.awt.printerjob = sun.awt.windows.WPrinterJob java.class.path = java.class.version = 55.0 java.home = C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot java.io.tmpdir = C:\Users\LY-CHE~1\AppData\Local\Temp\ java.library.path = C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot\bin C:\WINDOWS\Sun\Java\bin C:\WINDOWS\system32 C:\WINDOWS C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot\bin D:\app\client\UserName\product\12.2.0\client_1\bin C:\ProgramData\Oracle\Java\javapath D:\app\UserName\product\11.2.0\client_1\bin C:\Program Files (x86)\Common Files\Oracle\Java\javapath C:\WINDOWS\system32 C:\WINDOWS C:\WINDOWS\System32\Wbem C:\WINDOWS\System32\WindowsPowerShell\v1.0\ C:\WINDOWS\System32\OpenSSH\ C:\Program Files\TortoiseSVN\bin C:\Program Files\TortoiseGit\bin D:\Program Files\Git\cmd C:\Program Files\Microsoft SQL Server\150\Tools\Binn\ C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\ C:\Program Files\dotnet\ C:\Users\UserName\AppData\Local\Microsoft\WindowsApps D:\Users\UserName\AppData\Local\Programs\Microsoft VS Code\bin C:\Users\UserName\.dotnet\tools D:\Users\UserName\AppData\Local\Programs\Fiddler . java.runtime.name = OpenJDK Runtime Environment java.runtime.version = 11.0.16.1+1-LTS java.specification.name = Java Platform API Specification java.specification.vendor = Oracle Corporation java.specification.version = 11 java.vendor = Microsoft java.vendor.url = https://www.microsoft.com java.vendor.url.bug = https://github.com/microsoft/openjdk/issues java.vendor.version = Microsoft-40648 java.version = 11.0.16.1 java.version.date = 2022-08-12 java.vm.compressedOopsMode = Zero based java.vm.info = mixed mode java.vm.name = OpenJDK 64-Bit Server VM java.vm.specification.name = Java Virtual Machine Specification java.vm.specification.vendor = Oracle Corporation java.vm.specification.version = 11 java.vm.vendor = Microsoft java.vm.version = 11.0.16.1+1-LTS jdk.debug = release line.separator = \r \n os.arch = amd64 os.name = Windows 10 os.version = 10.0 path.separator = ; sun.arch.data.model = 64 sun.boot.library.path = C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot\bin sun.cpu.endian = little sun.cpu.isalist = amd64 sun.desktop = windows sun.io.unicode.encoding = UnicodeLittle sun.java.launcher = SUN_STANDARD sun.jnu.encoding = GBK sun.management.compiler = HotSpot 64-Bit Tiered Compilers sun.os.patch.level = sun.stderr.encoding = ms936 sun.stdout.encoding = ms936 user.country = CN user.dir = C:\Users\UserName user.home = C:\Users\UserName user.language = zh user.name = UserName user.script = user.timezone = user.variant = openjdk version "11.0.16.1" 2022-08-12 LTS OpenJDK Runtime Environment Microsoft-40648 (build 11.0.16.1+1-LTS) OpenJDK 64-Bit Server VM Microsoft-40648 (build 11.0.16.1+1-LTS, mixed mode)
输出的内容比较多,认真找可以找到user.home = C:\Users\UserName 其中UserName为你的登录用户名。
2、解决问题:
现在修改办法已经清楚了,要么修改java 的user.home变量,要么修改IDEA的配置文件不使用user.home变量,直接配一个固定的目录。我最终决定挑个简单的直接改一个固定目录,修改完后如下:
接下来就是保存文件,重启IDEA,检查效最了。最终C盘的空间再也不会因为运行IDEA而大量减少了,没了焦虑又可以安心撸代码了。
点赞(0)
请不要重复点赞
评论列表