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.html

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.htmljava