You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/MinecraftApi/Watchdog.md
+48-13Lines changed: 48 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
1
# Watchdog
2
2
3
-
Watchdog is a performance watchdog system that is enabled in Minecraft script plugins by default.
3
+
Watchdog is a performance system for script engine that is enabled in Minecraft script plugins by default.
4
4
5
5
## Server properties
6
6
7
-
Watchdog configuration can be modified via `server.properties` in Dedicated Server. This features are added since 1.19.20.
7
+
Watchdog configuration can be modified via `server.properties` in [Dedicated Server](https://www.minecraft.net/en-us/download/server/bedrock). This features are added since 1.19.20.
# Sets the watchdog threshold for slow scripts over multiple ticks (default = 2ms)
20
20
script-watchdog-slow-threshold=2
21
21
22
-
# Saves and shuts down the world when the combined memory usage exceeds the given threshold (in megabytes). Setting this value to 0 disables the limit. (default = 250)
22
+
# Saves and shuts down the world when the combined memory usage exceeds the given threshold (in megabytes).
23
+
# Setting this value to 0 disables the limit. (default = 250)
23
24
script-watchdog-memory-limit=250
24
25
25
-
# Produces a content log warning when the combined memory usage exceeds the given threshold (in megabytes). Setting this value to 0 disables the warning. (default = 100)
26
+
# Produces a content log warning when the combined memory usage exceeds the given threshold (in megabytes).
27
+
# Setting this value to 0 disables the warning. (default = 100)
26
28
script-watchdog-memory-warning=100
27
29
28
30
# Enables watchdog exception handling via the events.beforeWatchdogTerminate event (default = true)
These watchdog errors are thrown with `[Watchdog]` label in error.
41
43
42
-
- Slow-running script detected in behavior pack '%s' (x ms average)
44
+
---
43
45
44
-
Script runtime is delayed by over a certain timeframe. This
46
+
### Slow-running script detected in behavior pack '%s' (x ms average)
45
47
46
-
- x ms script spike detected in behavior pack '%s'
48
+
Script runtime is delayed by over a certain timeframe.
49
+
50
+
---
51
+
52
+
### x ms script spike detected in behavior pack '%s'
47
53
48
54
There is a spike in script runtime.
49
55
50
-
- Out of memory exception detected in behavior pack '%s'
56
+
---
57
+
58
+
### Out of memory exception detected in behavior pack '%s'
51
59
52
60
This error occurs when the combined memory usage exceeds.
53
61
54
62
This saves and shuts down the world by Watchdog termination and cannot be canceled using `BeforeWatchdogTerminateEvent`.
55
63
56
-
- x ms script hang detected in behavior pack '%s'
64
+
---
65
+
66
+
### x ms script hang detected in behavior pack '%s'
57
67
58
68
The scripts freezes at a certain location of your script for more than the watchdog threshold for single tick.
59
69
60
70
This is usually caused by iteration, such as `while` loop and `for` loop.
61
71
62
-
- Stack overflow detected in behavior pack '%s'
72
+
---
73
+
74
+
### Stack overflow detected in behavior pack '%s'
63
75
64
76
Occurs when there is a recursive function (a function that calls itself) without an exit point.
65
77
66
-
- High memory usage detected
78
+
---
79
+
80
+
### High memory usage detected
67
81
68
82
Produces a content log warning when the combined memory usage exceeds the given threshold in megabytes.
69
83
70
-
- Unhandled critical exception of type '%s' in behavior pack '%s'
84
+
---
71
85
72
-
Produces a content log error when an unhandled critical exception occurs.
86
+
### Unhandled critical exception of type '%s' in behavior pack '%s'
87
+
88
+
Produces a content log error when an unhandled critical exception occurs.
89
+
90
+
There are multiple reason that a watchdog is deciding to terminate execution of a behavior pack's script.
91
+
-`hang`: script is not responsive due to a hang or infinite loop.
92
+
-`stackOverflow`: a long, and potentially infinite chain of function calls.
93
+
94
+
## Script API
95
+
96
+
Using Minecraft's scripting API, you are able to connect to a callback that will be called when a script runtime is being terminated due to a violation of the performance watchdog system.
97
+
98
+
This event allows you to cancel the termination of the script runtime to prevent from the watchdog from stopping the server from running. Note that depending on server configuration settings, cancellation of the termination may not be allowed.
0 commit comments