File tree Expand file tree Collapse file tree 2 files changed +95
-0
lines changed
components/jvm-memory-visualizer Expand file tree Collapse file tree 2 files changed +95
-0
lines changed Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div class =" logic-table" >
3
+ <a-table :data =" logicList" :pagination =" false" >
4
+ <template #columns >
5
+ <a-table-column title =" 逻辑名称" data-index =" name" :width =" 200" />
6
+ <a-table-column title =" 描述" data-index =" desc" />
7
+ <a-table-column title =" 状态" :width =" 100" >
8
+ <template #cell =" { record } " >
9
+ <template v-if =" record .implemented " >
10
+ <a-switch v-if =" record.configurable" v-model =" record.enabled"
11
+ @change =" handleLogicChange(record)" >
12
+ <template #checked >已启用</template >
13
+ <template #unchecked >已禁用</template >
14
+ </a-switch >
15
+ <span v-else >{{ record.enabled ? '已启用' : '已禁用' }}</span >
16
+ </template >
17
+ <template v-else >
18
+ <span >未实现</span >
19
+ </template >
20
+ </template >
21
+ </a-table-column >
22
+ </template >
23
+ </a-table >
24
+ </div >
25
+ </template >
26
+
27
+ <script setup lang="ts">
28
+ import { ref } from ' vue' ;
29
+
30
+ interface LogicItem {
31
+ id: string ;
32
+ name: string ;
33
+ desc: string ;
34
+ enabled: boolean ;
35
+ configurable: boolean ;
36
+ implemented: boolean ;
37
+ }
38
+
39
+ const logicList = ref <LogicItem []>([
40
+ {
41
+ id: ' eden_sweep' ,
42
+ name: ' 优先 Eden 分配' ,
43
+ desc: ' 优先将对象分配到 Eden 区' ,
44
+ enabled: true ,
45
+ configurable: false ,
46
+ implemented: true
47
+ },
48
+ {
49
+ id: ' pretenure_size_threshold' ,
50
+ name: ' 大对象直入老年代' ,
51
+ desc: ' 当对象大小超过 Eden 区时,直接在老年代分配(可以通过 -XX:PretenureSizeThreshold 参数配置)' ,
52
+ enabled: true ,
53
+ configurable: false ,
54
+ implemented: false
55
+ },
56
+ {
57
+ id: ' dynamic_age_threshold' ,
58
+ name: ' 动态年龄判定' ,
59
+ desc: ' 当 Survivor 区中相同年龄对象大小总和超过 Survivor 区的一半时,年龄大于等于该年龄的对象直接进入老年代' ,
60
+ enabled: false ,
61
+ configurable: false ,
62
+ implemented: false
63
+ }
64
+ ]);
65
+
66
+ const emit = defineEmits ([' logicChange' ]);
67
+
68
+ const handleLogicChange = (logic : LogicItem ) => {
69
+ emit (' logicChange' , logic );
70
+ };
71
+ </script >
72
+
73
+ <style scoped>
74
+ .logic-table {
75
+ background : white ;
76
+ }
77
+ </style >
Original file line number Diff line number Diff line change 11
11
<a-form-item >
12
12
<a-button @click =" restartJvm" class =" restart-button" :loading =" isRestarting" >重启 JVM</a-button >
13
13
</a-form-item >
14
+ <a-form-item >
15
+ <a-button @click =" showLogicTable" >内存管理逻辑</a-button >
16
+ </a-form-item >
14
17
</a-form >
15
18
16
19
<!-- 对象创建表单 -->
116
119
</template >
117
120
</a-table >
118
121
</a-modal >
122
+
123
+ <!-- 内存管理逻辑弹窗 -->
124
+ <a-modal v-model:visible =" showLogicModal" title =" 内存管理逻辑" :footer =" false" width =" 1000px" >
125
+ <LogicTable @logicChange =" handleLogicChange" />
126
+ </a-modal >
119
127
</template >
120
128
121
129
<script setup lang="ts">
122
130
import { ref , computed , onBeforeMount , reactive } from ' vue' ;
123
131
import { Message } from ' @arco-design/web-vue' ;
124
132
import MemorySpace from ' @/components/jvm-memory-visualizer/MemorySpace.vue' ;
133
+ import LogicTable from ' @/components/jvm-memory-visualizer/LogicTable.vue' ;
125
134
import type { HeapObject } from ' @/types' ;
126
135
127
136
onBeforeMount (() => {
@@ -135,6 +144,11 @@ onBeforeMount(() => {
135
144
// 重启状态
136
145
const isRestarting = ref (false );
137
146
const showHelpModal = ref (false );
147
+ const showLogicModal = ref (false );
148
+
149
+ const showLogicTable = () => {
150
+ showLogicModal .value = true ;
151
+ };
138
152
139
153
const jvmArgsHelp = [
140
154
{
@@ -655,6 +669,10 @@ const toggleGarbageCollectable = (obj: HeapObject) => {
655
669
obj .isGarbageCollectable = ! obj .isGarbageCollectable ;
656
670
operationLogs .value .unshift (` 切换对象 ${obj .name } 的可回收状态为: ${obj .isGarbageCollectable ? ' 可回收' : ' 不可回收' } ` );
657
671
};
672
+
673
+ const handleLogicChange = (logic : { id: string ; enabled: boolean }) => {
674
+ operationLogs .value .unshift (` ${logic .enabled ? ' 启用' : ' 禁用' }逻辑: ${logic .id } ` );
675
+ };
658
676
</script >
659
677
660
678
<style scoped>
You can’t perform that action at this time.
0 commit comments