Uses 6517K of libraries. Click here for Pure Java version (9211L/48K).
1 | !7 |
2 | |
3 | set flag OshiNotSticky. |
4 | |
5 | cm whatever {
|
6 | transient SimpleLiveValue<S> lvStatus = stringLiveValue(); |
7 | switchable int max = 1024; |
8 | switchable double interval = 10.0; |
9 | |
10 | visual jCenteredLiveValueLabel(lvStatus); |
11 | |
12 | start {
|
13 | lvStatus.set("Current threshold: " + max + " GB. You have 60s to change this value in this module's menu.");
|
14 | doEvery(interval, r checkIt); // allow 60 seconds after start to change max value |
15 | } |
16 | |
17 | long usedMegabytes() {
|
18 | ret oshi_currentProcessResidentSize()/oneMegabyte(); |
19 | } |
20 | |
21 | void checkIt enter {
|
22 | long megabytes = usedMegabytes(); |
23 | lvStatus.set("Emergency restart enabled. Memory use: " + megabytes + "/" + max + " MB");
|
24 | if (megabytes >= max) {
|
25 | dm_gc(); |
26 | sleepSeconds(5); |
27 | megabytes = usedMegabytes(); |
28 | if (megabytes >= max) {
|
29 | localMechLog("Emergency shutdowns", "Emergency shutdown at " + localDateWithSeconds() + " because of too much memory use ("+ megabytes + " MB)");
|
30 | dm_restartOS(); |
31 | } |
32 | } |
33 | } |
34 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1016395 |
| Snippet name: | Emergency Restart on too much memory use |
| Eternal ID of this version: | #1016395/14 |
| Text MD5: | b161e1739a881c1863ba1643f601660c |
| Transpilation MD5: | 71f0a59829cc362584faf6771271d49b |
| Author: | stefan |
| Category: | javax / stefan's os |
| Type: | JavaX source code (Dynamic Module) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2022-02-05 00:52:11 |
| Source code size: | 1038 bytes / 34 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 779 / 256733 |
| Version history: | 13 change(s) |
| Referenced in: | [show references] |