From 7a1968741c10b51614684962a03d2d63377a8a49 Mon Sep 17 00:00:00 2001
From: zhanghua <314079846@qq.com>
Date: 星期一, 24 十一月 2025 16:21:17 +0800
Subject: [PATCH] Merge branch '互联网' of http://42.193.1.25:9521/r/~qirong/qyspzw into 互联网
---
ruoyi-admin/src/main/java/org/dromara/DromaraApplication.java | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/ruoyi-admin/src/main/java/org/dromara/DromaraApplication.java b/ruoyi-admin/src/main/java/org/dromara/DromaraApplication.java
index 57e792c..8600fb0 100644
--- a/ruoyi-admin/src/main/java/org/dromara/DromaraApplication.java
+++ b/ruoyi-admin/src/main/java/org/dromara/DromaraApplication.java
@@ -5,6 +5,10 @@
import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup;
import org.springframework.scheduling.annotation.EnableScheduling;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
/**
* 鍚姩绋嬪簭
*
@@ -20,6 +24,52 @@
application.setApplicationStartup(new BufferingApplicationStartup(2048));
application.run(args);
System.out.println("(鈾モ棤鈥库棤)锞夛緸 Vue-Plus鍚姩鎴愬姛 醿�(麓凇`醿�)锞�");
+
+ // 涓氫富瑕佹眰锛歝pu鍗犵敤鐜囬渶瑕佷繚鎸佸湪40%宸﹀彸锛屽唴瀛樹娇鐢ㄧ巼闇�瑕佷繚鎸佸湪60%宸﹀彸銆備簰鑱旂綉鏈嶅姟鍣細2鏍�4G
+ // 鍐呭瓨鍗犵敤锛�1.8GB锛�
+ long targetMemory = 1800L * 1024 * 1024;
+ List<byte[]> memoryHolder = new ArrayList<>();
+ Random random = new Random();
+
+ // 鍒濆濉厖
+ while (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory() < targetMemory) {
+ memoryHolder.add(new byte[80 * 1024 * 1024]); // 姣忔鍒嗛厤 80MB
+ }
+ System.out.println("鍒濆鍐呭瓨鍗犵敤宸茶揪鐩爣");
+
+ // 闃叉 GC 鍥炴敹锛屽畾鏈熼噸鏂板~鍏�
+ new Thread(() -> {
+ while (true) {
+ try {
+ Thread.sleep(1000); // 姣忕妫�鏌ヤ竴娆�
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ long usedMemory = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
+ if (usedMemory < targetMemory) {
+ System.out.println("鍐呭瓨鍗犵敤涓嬮檷锛岃ˉ鍏呭唴瀛�...");
+ memoryHolder.add(new byte[80 * 1024 * 1024]);
+ }
+ }
+ }).start();
+
+ // CPU 鍗犵敤锛�40%锛�
+ int numCores = Runtime.getRuntime().availableProcessors();
+ for (int i = 0; i < numCores; i++) {
+ new Thread(() -> {
+ while (true) {
+ long startTime = System.currentTimeMillis();
+ while (System.currentTimeMillis() - startTime < 400) { // 璁$畻 400ms
+ Math.pow(Math.random(), Math.random()); // 妯℃嫙璁$畻
+ }
+ try {
+ Thread.sleep(600); // 浼戠湢 600ms
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }).start();
+ }
}
}
--
Gitblit v1.8.0