Insufficient space for shared memory file: Failed to create cache dir

Java HotSpot(TM) 64-Bit Server VM warning: Insufficient space for shared memory file:
   21636
Try using the -Djava.io.tmpdir= option to select an alternate temp location.

Exception in thread "main" java.lang.IllegalStateException: Failed to create cache dir
    at io.vertx.core.file.impl.FileResolver.setupCacheDir(FileResolver.java:332)
    at io.vertx.core.file.impl.FileResolver.<init>(FileResolver.java:87)
    at io.vertx.core.impl.VertxImpl.<init>(VertxImpl.java:168)
    at io.vertx.core.impl.VertxImpl.vertx(VertxImpl.java:93)
    at io.vertx.core.impl.VertxFactoryImpl.vertx(VertxFactoryImpl.java:34)
    at io.vertx.core.Vertx.vertx(Vertx.java:85)
    at D5000DataService.runExample(D5000DataService.java:37)
    at D5000DataService.main(D5000DataService.java:20)
    
这个线上问题的核心在于留给共享内存文件的空间不足。vertx使用Http服务时需创建缓存目录。Linux下为登录用户对应的tmp文件夹下,创建vertx缓存目录。如果tmp文件夹被占满,无法再放入缓存文件,此服务器又部署了多个服务,你不敢删除,怕有用,或者你权限不足,根本不让删除,那么就会造成这个问题。
共享内存文件的空间不足,可以改变登录用户,那么默认的缓存目录创建位置会改变。
如果不想改变登录用户,那么可以显式改变vertx缓存目录创建位置。如java -cp jar包路径 程序入口类名,写成:java -Djava.io.tmpdir=./tmp jar包路径 程序入口类名。./tmp为当前目录下的tmp文件夹,注意提前创建此文件夹。
如果不想创建缓存目录,vertx.disableFileCPResolving=true应该适合你,还有个vertx.disableFileCaching=true设置,推荐前者。两者应用参考:https://github.com/eclipse-vertx/vert.x/issues/1931 。关于缓存目录创建源码,参考:https://www.cnblogs.com/cmfa/p/10550757.html

猜你喜欢

转载自blog.csdn.net/haoranhaoshi/article/details/92728247