ソースを参照

数据同步调整-资源释放

sangwenwei 5 ヶ月 前
コミット
e2dcb998e4

+ 8 - 0
src/main/java/com/jeeplus/modules/centerservice/config/ConnectionService.java

@@ -70,9 +70,17 @@ public class ConnectionService {
 //            isConnected = false; // 连接失败,更新状态
             JedisUtils.set("ccpmConnect", "false", 24);
             System.out.println("Connection failed: " + e.getMessage());
+        } finally {
+            // 在任务完成后清理资源,
+            cleanUpResources();
         }
     }
 
+    private void cleanUpResources() {
+
+        System.gc();  // 显式调用垃圾回收
+    }
+
     // 可选:停止检查连接的方法
     public void stopCheckingConnection() {
         if (scheduler != null) {