内存泄漏
Memory Leak 是一款用于生成可控内存压力的 Minecraft 服务器模组。它会在设定的服务器刻数内分配内存,并通过 Boss 条向管理员显示进度。
请在测试服务器上使用该模组。过度的内存分配可能导致服务器崩溃。
支持的 Minecraft 版本
| Minecraft |
Fabric 和 Quilt |
NeoForge |
Forge |
Java |
| 1.20.1 |
是 |
|
是 |
17 |
| 1.21.1 |
是 |
是 |
|
21 |
| 1.21.10 |
是 |
是 |
|
21 |
| 1.21.11 |
是 |
是 |
|
21 |
| 26.1.1, 26.1.2, 26.2 |
是 |
是 |
|
25 |
| 26.3 |
是 |
是 |
|
25 |
从 Modrinth 下载对应你的 Minecraft 版本和加载器的 jar 文件,并将其放入服务器的 mods 目录中。在 Fabric 和 Quilt 上,还需为你的 Minecraft 版本安装 Fabric API。客户端无需安装 Memory Leak 即可加入服务器。对于 Minecraft 26.1.1 和 26.2,请使用 26.1.2 的 jar 文件。
命令
这些命令需要 4 级操作员权限或 Minecraft 中等效的管理员权限。
| 命令 |
描述 |
/leak start <MB> <seconds> |
在 1 到 3,600 秒内分配 1 到 10,000 MB 的内存。 |
/leak stop |
停止分配并保持已泄漏的内存。 |
/leak clear |
停止分配并释放所有已泄漏的内存。 |
/leak status |
显示当前进度或总的泄漏内存量。 |
构建模组
将 JAVA_HOME 设置为 JDK 25 的安装路径,并从仓库根目录运行 ./gradlew buildAll。在 Windows 上使用 .\gradlew.bat buildAll。Gradle 会查找或下载各个节点所需的 JDK。该任务会运行核心测试,并将每个模组 jar 写入 versions/<node>/build/libs/,将每个插件 jar 写入 <platform>/build/libs/。
若要构建单个 jar,请运行 ./gradlew :<node>:assemble,例如 ./gradlew :1.20.1-forge:assemble。
添加 Minecraft 版本
- 复制现有加载器的
versions/<minecraft>-<loader>/gradle.properties 到新节点目录中。设置 Minecraft、Java、加载器和 API 的版本号。
- 将
minecraft_versions 设置为你计划验证的逗号分隔的 Minecraft 发布版本列表。此列表控制加载器元数据和 Modrinth 游戏版本。如果第二个发布版本使用不同的运行时依赖项,请提供 fabric_api_version_<minecraft> 或 loader_version_<minecraft>。
- 在
src/main/java/com/hezaerd/memoryleak/MemoryLeak.java 中使用 Stonecutter 条件进行 Minecraft 或加载器 API 更改。保持分配逻辑和命令回复在 core/ 中。
- 构建矩阵并对新节点及其列表中的每个发布版本进行冒烟测试。
运行专用服务器冒烟测试
将 JAVA_HOME_17、JAVA_HOME_21 和 JAVA_HOME_25 设置为相应的 JDK 目录并构建 jar 文件。使用 Python 3.10 或更高版本运行脚本。传递 --accept-eula 参数即接受 Minecraft EULA 以用于测试服务器。
python scripts/smoke-mods.py --accept-eula
python scripts/smoke-mods.py --accept-eula 1.20.1-forge
该脚本使用 .smoke/ 下的临时服务器目录。它将控制台和安装程序日志保留在该目录下以供检查。
服务器插件
每个平台只需构建一次。将匹配的 jar 复制到服务器的插件目录中。
| 平台 |
模块 build/libs 目录中的 Jar |
兼容性 |
安装位置 |
| Bukkit, Spigot, Paper, Purpur, Folia |
memory-leak-bukkit-<version>.jar |
Minecraft 1.13.2 至 26.3,前提是平台有相应发布版本 |
plugins/ |
| Velocity |
memory-leak-velocity-<version>.jar |
Velocity 3.5.1 和 4.3.1 |
plugins/ |
| BungeeCord, Waterfall |
memory-leak-bungee-<version>.jar |
BungeeCord build 2111 和 Waterfall final build 615 |
plugins/ |
| Sponge |
memory-leak-sponge-<version>.jar |
Minecraft 1.21.10 上的 SpongeAPI 17 |
mods/ |
命令和 Boss 条使用 memoryleak.admin 权限。Bukkit 和 Sponge 默认授予操作员访问权限。代理服务器没有 Minecraft 操作员列表。代理控制台默认拥有访问权限,而玩家访问则需要代理权限。BungeeCord 和 Waterfall 没有 Boss 条 API。
Bukkit jar 在基于 Bukkit 的服务器上使用 Bukkit 调度器,并在运行时选择 Folia 的全局区域调度器。反射机制使该 jar 与 Spigot 1.13.2 API 兼容。冒烟测试涵盖了范围两端的 Paper 以及近期的 Folia 和 Purpur。Spigot 和 CraftBukkit 需要 BuildTools,因此它们的兼容性是基于在 Paper 和 Purpur 上执行的 Bukkit API 得出的。Waterfall 已停止维护。代理服务器 Modrinth 游戏标签描述了所测试构建版本的客户端协议支持情况。BungeeCord 和 Waterfall 列表使用了它们共享的范围直到 26.2。
构建并冒烟测试插件
将 JAVA_HOME 设置为 JDK 25。使用 Python 3.8 或更高版本。在 Windows PowerShell 中运行以下命令。
.\gradlew.bat --configure-on-demand :core:test :bukkit:build :velocity:build :bungee:build :sponge:build
$java8 = .\gradlew.bat --configure-on-demand -q :bukkit:printJava8
python scripts/smoke-plugins.py --java8 $java8 --java21 "$env:JAVA21_HOME/bin/java.exe" --java25 "$env:JAVA_HOME/bin/java.exe"
在运行冒烟测试之前,将 JAVA21_HOME 设置为 Java 21 的安装路径。Gradle 任务通过 Foojay 为 Paper 1.13.2 配置 Java 8。传递服务器名称以运行子集,或使用 --help 列出名称。每次运行都会为其位于 build/smoke-plugins/ 下的全新服务器目录接受 EULA,并将控制台日志保存其中。
许可证
Memory Leak 根据 MIT License 授权。
Memory Leak
Memory Leak is a Minecraft server mod for generating controlled memory pressure. It allocates memory over a set number of server ticks and shows progress in a boss bar for administrators.
Use it on test servers. Excessive allocations can crash a server.
Supported Minecraft versions
| Minecraft |
Fabric and Quilt |
NeoForge |
Forge |
Java |
| 1.20.1 |
Yes |
|
Yes |
17 |
| 1.21.1 |
Yes |
Yes |
|
21 |
| 1.21.10 |
Yes |
Yes |
|
21 |
| 1.21.11 |
Yes |
Yes |
|
21 |
| 26.1.1, 26.1.2, 26.2 |
Yes |
Yes |
|
25 |
| 26.3 |
Yes |
Yes |
|
25 |
Download the jar for your Minecraft version and loader from Modrinth and place it in the server's mods directory. On Fabric and Quilt, also install Fabric API for your Minecraft version. Clients can join without Memory Leak installed. For Minecraft 26.1.1 and 26.2, use the 26.1.2 jar.
Commands
The commands require level 4 operator access or Minecraft's equivalent administrator permission.
| Command |
Description |
/leak start <MB> <seconds> |
Allocate 1 to 10,000 MB over 1 to 3,600 seconds. |
/leak stop |
Stop allocating and keep the leaked memory. |
/leak clear |
Stop allocating and release all leaked memory. |
/leak status |
Show the current progress or total leaked memory. |
Build the mods
Set JAVA_HOME to a JDK 25 installation and run ./gradlew buildAll from the repository root. On Windows use .\gradlew.bat buildAll. Gradle finds or downloads the JDKs required by the individual nodes. The task runs the core tests and writes each mod jar to versions/<node>/build/libs/ and each plugin jar to <platform>/build/libs/.
To build one jar, run ./gradlew :<node>:assemble, for example ./gradlew :1.20.1-forge:assemble.
Add a Minecraft version
- Copy an existing loader's
versions/<minecraft>-<loader>/gradle.properties into a new node directory. Set the Minecraft, Java, loader, and API versions.
- Set
minecraft_versions to the comma-separated Minecraft releases you plan to verify. This list controls loader metadata and Modrinth game versions. Supply fabric_api_version_<minecraft> or loader_version_<minecraft> if a second release uses a different runtime dependency.
- Make Minecraft or loader API changes in
src/main/java/com/hezaerd/memoryleak/MemoryLeak.java using Stonecutter conditions. Keep allocation and command replies in core/.
- Build the matrix and smoke-test the new node and every release in its list.
Run dedicated server smoke tests
Set JAVA_HOME_17, JAVA_HOME_21, and JAVA_HOME_25 to the corresponding JDK directories and build the jars. Run the script with Python 3.10 or later. Passing --accept-eula accepts the Minecraft EULA for the test servers.
python scripts/smoke-mods.py --accept-eula
python scripts/smoke-mods.py --accept-eula 1.20.1-forge
The script uses throwaway server directories under .smoke/. It leaves the console and installer logs there for inspection.
Server plugins
Build once per platform. Copy the matching jar to the server's plugin directory.
| Platform |
Jar in the module's build/libs directory |
Compatibility |
Install in |
| Bukkit, Spigot, Paper, Purpur, Folia |
memory-leak-bukkit-<version>.jar |
Minecraft 1.13.2 through 26.3, where the platform has a release |
plugins/ |
| Velocity |
memory-leak-velocity-<version>.jar |
Velocity 3.5.1 and 4.3.1 |
plugins/ |
| BungeeCord, Waterfall |
memory-leak-bungee-<version>.jar |
BungeeCord build 2111 and Waterfall final build 615 |
plugins/ |
| Sponge |
memory-leak-sponge-<version>.jar |
SpongeAPI 17 on Minecraft 1.21.10 |
mods/ |
The command and boss bar use the memoryleak.admin permission. Bukkit and Sponge grant access to operators by default. Proxies have no Minecraft operator list. The proxy console has access by default, and player access requires the proxy permission. BungeeCord and Waterfall have no boss bar API.
The Bukkit jar uses the Bukkit scheduler on Bukkit-derived servers and selects Folia's global region scheduler at runtime. Reflection keeps the jar compatible with the Spigot 1.13.2 API. The smoke test covers Paper at both ends of the range and recent Folia and Purpur. Spigot and CraftBukkit require BuildTools, so their compatibility is based on the Bukkit API exercised on Paper and Purpur. Waterfall is end-of-life. Proxy Modrinth game tags describe the tested builds' client protocol support. The BungeeCord and Waterfall listing uses their shared range through 26.2.
Build and smoke-test the plugins
Set JAVA_HOME to JDK 25. Use Python 3.8 or newer. Run these commands in Windows PowerShell.
.\gradlew.bat --configure-on-demand :core:test :bukkit:build :velocity:build :bungee:build :sponge:build
$java8 = .\gradlew.bat --configure-on-demand -q :bukkit:printJava8
python scripts/smoke-plugins.py --java8 $java8 --java21 "$env:JAVA21_HOME/bin/java.exe" --java25 "$env:JAVA_HOME/bin/java.exe"
Set JAVA21_HOME to a Java 21 installation before running the smoke test. The Gradle task provisions Java 8 through Foojay for Paper 1.13.2. Pass server names to run a subset, or use --help to list the names. Each run accepts the EULA for its fresh server directory under build/smoke-plugins/ and saves the console log there.
License
Memory Leak is licensed under the MIT License.
评论 0
登录后参与评分
还没有评论,来抢沙发吧