docker-minecraft-bedrock-server icon indicating copy to clipboard operation
docker-minecraft-bedrock-server copied to clipboard

ram limitation usage

Open kruonos opened this issue 1 year ago • 15 comments

for some reason the docker image don't use more than 2GB of ram, I tried everything, but when it uses 2GB the server can't render new dimensions or new chunks, i have 24gb of ram on oracle, 5 vm.standard.a1 flex, performance isn't an issue, but the ram usage i simple can't understand, can someone help?

docker inspects returns the following:

ubuntu@instance-20250401-2323:~$ docker inspect 81d116712e5f [ { "Id": "81d116712e5febce6b9c6f79472d3671f816f8b35fc36efb00c2191428a25924", "Created": "2025-04-02T03:00:23.262472797Z", "Path": "/usr/local/bin/entrypoint-demoter", "Args": [ "--match", "/data", "--debug", "--stdin-on-term", "stop", "/opt/bedrock-entry.sh" ], "State": { "Status": "running", "Running": true, "Paused": false, "Restarting": false, "OOMKilled": false, "Dead": false, "Pid": 3026, "ExitCode": 0, "Error": "", "StartedAt": "2025-04-02T03:00:23.303904186Z", "FinishedAt": "0001-01-01T00:00:00Z", "Health": { "Status": "healthy", "FailingStreak": 0, "Log": [ { "Start": "2025-04-02T03:25:40.309585696Z", "End": "2025-04-02T03:25:40.345380031Z", "ExitCode": 0, "Output": "127.0.0.1:19132 : version=1.21.71 online=0 max=10" }, { "Start": "2025-04-02T03:26:10.346512616Z", "End": "2025-04-02T03:26:10.378780028Z", "ExitCode": 0, "Output": "127.0.0.1:19132 : version=1.21.71 online=0 max=10" }, { "Start": "2025-04-02T03:26:40.379580941Z", "End": "2025-04-02T03:26:40.41214939Z", "ExitCode": 0, "Output": "127.0.0.1:19132 : version=1.21.71 online=0 max=10" }, { "Start": "2025-04-02T03:27:10.413235165Z", "End": "2025-04-02T03:27:10.445338605Z", "ExitCode": 0, "Output": "127.0.0.1:19132 : version=1.21.71 online=0 max=10" }, { "Start": "2025-04-02T03:27:40.446295031Z", "End": "2025-04-02T03:27:40.482640188Z", "ExitCode": 0, "Output": "127.0.0.1:19132 : version=1.21.71 online=0 max=10" } ] } }, "Image": "sha256:9b1921fd7c707b9e46a03d680853345f596f5db2641a7ea385baccf084ba68fc", "ResolvConfPath": "/var/lib/docker/containers/81d116712e5febce6b9c6f79472d3671f816f8b35fc36efb00c2191428a25924/resolv.conf", "HostnamePath": "/var/lib/docker/containers/81d116712e5febce6b9c6f79472d3671f816f8b35fc36efb00c2191428a25924/hostname", "HostsPath": "/var/lib/docker/containers/81d116712e5febce6b9c6f79472d3671f816f8b35fc36efb00c2191428a25924/hosts", "LogPath": "/var/lib/docker/containers/81d116712e5febce6b9c6f79472d3671f816f8b35fc36efb00c2191428a25924/81d116712e5febce6b9c6f79472d3671f816f8b35fc36efb00c2191428a25924-json.log", "Name": "/bds", "RestartCount": 0, "Driver": "overlay2", "Platform": "linux", "MountLabel": "", "ProcessLabel": "", "AppArmorProfile": "docker-default", "ExecIDs": null, "HostConfig": { "Binds": [ "/home/ubuntu/data:/data" ], "ContainerIDFile": "", "LogConfig": { "Type": "json-file", "Config": {} }, "NetworkMode": "bridge", "PortBindings": { "19132/udp": [ { "HostIp": "", "HostPort": "19132" } ] }, "RestartPolicy": { "Name": "no", "MaximumRetryCount": 0 }, "AutoRemove": false, "VolumeDriver": "", "VolumesFrom": null, "ConsoleSize": [ 38, 147 ], "CapAdd": null, "CapDrop": null, "CgroupnsMode": "private", "Dns": [], "DnsOptions": [], "DnsSearch": [], "ExtraHosts": null, "GroupAdd": null, "IpcMode": "private", "Cgroup": "", "Links": null, "OomScoreAdj": 0, "PidMode": "", "Privileged": false, "PublishAllPorts": false, "ReadonlyRootfs": false, "SecurityOpt": null, "UTSMode": "", "UsernsMode": "", "ShmSize": 67108864, "Runtime": "runc", "Isolation": "", "CpuShares": 0, "Memory": 25769803776, "NanoCpus": 0, "CgroupParent": "", "BlkioWeight": 0, "BlkioWeightDevice": [], "BlkioDeviceReadBps": [], "BlkioDeviceWriteBps": [], "BlkioDeviceReadIOps": [], "BlkioDeviceWriteIOps": [], "CpuPeriod": 0, "CpuQuota": 0, "CpuRealtimePeriod": 0, "CpuRealtimeRuntime": 0, "CpusetCpus": "", "CpusetMems": "", "Devices": [], "DeviceCgroupRules": null, "DeviceRequests": null, "MemoryReservation": 0, "MemorySwap": 51539607552, "MemorySwappiness": null, "OomKillDisable": null, "PidsLimit": null,

kruonos avatar Apr 02 '25 03:04 kruonos

You will need to contact Mojang about this. Their bedrock server doesn't expose an option that I know of to set or increase a memory limit. As such, this image has no control over any memory limiting of the bedrock server.

itzg avatar Apr 02 '25 12:04 itzg

Yeah but in another server with x64_86 architecture it runs apparently without any ram limitation, is it only happening with me? At first it used 2 Gb of ram, now it's only using 1 GB, is there some kind of docker config or box64 that may cause it?

kruonos avatar Apr 02 '25 18:04 kruonos

It's probably not docker since your container config reports a memory config of

"Memory": 25769803776,

Seems unlikely it's box64, but that's a decent theory since that's going to be the main difference from the x86 binary running natively.

Just to double check, you're running docker directly on the Linux kernel and not within a VM on the VM? I ask because Docker Desktop on Linux runs within its own VM with its own memory allocation.

itzg avatar Apr 02 '25 20:04 itzg

@kruonos I am experiencing the same behavior. Although docker inspect says Memory is 0. I am running the Docker image on a Raspberry Pi 5

stwalser avatar Apr 26 '25 16:04 stwalser

@stwalser I'm running using box64, without docker, and the error continues, the only weird log that sometimes appear is [BOX64] Warning, block 0xf8f86b4a6f00 not found in p_blocks for Free, other than that nothing, also it still is limited to only 2 gb of ram, so i don't know what's going on

kruonos avatar Apr 27 '25 21:04 kruonos

@kruonos that would be great to report with box64. I had reported an unrelated issue with them before, but it's awkward since I have a layer of docker image to complicate my issue report them... and no further progress was made 😟

itzg avatar Apr 27 '25 21:04 itzg

OKAY I found the solution, box64 doesn't have the libjemalloc x64_86 library, and because of that the server can't allocate memory properly, so all we have to do is import the library from an x64_86 machine to the server's folder and allow box64 to use it, here is the output: ubuntu@instance-20250401-2323:~/voidborn$ BOX64_LD_LIBRARY_PATH=. LD_PRELOAD=./libjemalloc.so.2 box64 ./bedrock_server ERROR: ld.so: object './libjemalloc.so.2' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored. [BOX64] Box64 arm64 v0.3.5 2798c3c8 with Dynarec built on May 17 2025 06:29:24 [BOX64] Dynarec for ARM64, with extension: ASIMD AES CRC32 PMULL ATOMICS SHA1 SHA2 ERROR: ld.so: object './libjemalloc.so.2' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored. ERROR: ld.so: object './libjemalloc.so.2' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored. ERROR: ld.so: object './libjemalloc.so.2' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored. ERROR: ld.so: object './libjemalloc.so.2' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored. ERROR: ld.so: object './libjemalloc.so.2' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored. [BOX64] Running on Neoverse-N1 with 5 cores, pagesize: 4096 [BOX64] Will use hardware counter measured at 25.0 MHz emulating 3.2 GHz [BOX64] Detected 48bits at least of address space [BOX64] Counted 28 Env var [BOX64] BOX64 trying to Preload ./libjemalloc.so.2 [BOX64] Library search path: [BOX64] Binary search path: ./:bin/:/usr/local/sbin/:/usr/local/bin/:/usr/sbin/:/usr/bin/:/sbin/:/bin/:/usr/games/:/usr/local/games/:/snap/bin/ [BOX64] Looking for ./bedrock_server [BOX64] BOX64ENV: Variables overridden via env and/or RC file: BOX64_LD_LIBRARY_PATH=. [BOX64] Rename process to "bedrock_server" [BOX64] Using emulated ./libjemalloc.so.2 [BOX64] Redirecting overridden malloc from dynsym function for ./libjemalloc.so.2 [BOX64] Using native(wrapped) libm.so.6 [BOX64] Using emulated /usr/lib/box64-x86_64-linux-gnu/libstdc++.so.6 [BOX64] Using emulated /usr/lib/box64-x86_64-linux-gnu/libgcc_s.so.1 [BOX64] Using native(wrapped) libc.so.6 [BOX64] Using native(wrapped) ld-linux-x86-64.so.2 [BOX64] Using native(wrapped) libpthread.so.0 [BOX64] Using native(wrapped) libdl.so.2 [BOX64] Using native(wrapped) libutil.so.1 [BOX64] Using native(wrapped) librt.so.1 [BOX64] Using native(wrapped) libbsd.so.0 [BOX64] Using native(wrapped) libcurl.so.4 ERROR: ld.so: object './libjemalloc.so.2' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored. ERROR: ld.so: object './libjemalloc.so.2' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored. ERROR: ld.so: object './libjemalloc.so.2' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored. ERROR: ld.so: object './libjemalloc.so.2' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored. NO LOG FILE! - setting up server logging... [2025-05-18 11:01:55:504 INFO] Starting Server [2025-05-18 11:01:55:505 INFO] Version: 1.21.81.2 [2025-05-18 11:01:55:505 INFO] Session ID: cd9cb90f-1cd2-432f-ab45-2b99a7ccb8b1 [2025-05-18 11:01:55:505 INFO] Build ID: 33412274 [2025-05-18 11:01:55:505 INFO] Branch: r/21_u8 [2025-05-18 11:01:55:505 INFO] Commit ID: 85438e4ff033c9d002fbe5ab3155cd5241b4b61e [2025-05-18 11:01:55:505 INFO] Configuration: Publish [2025-05-18 11:01:55:513 INFO] Level Name: VoidReborn [2025-05-18 11:01:55:522 INFO] No CDN config file found for dedicated server [2025-05-18 11:01:55:523 INFO] Game mode: 0 Survival [2025-05-18 11:01:55:523 INFO] Difficulty: 3 HARD [2025-05-18 11:01:55:535 INFO] Content logging to console is enabled. [2025-05-18 11:01:56:545 INFO] Opening level 'worlds/VoidReborn/db' [2025-05-18 11:01:57:592 INFO] [SERVER] Pack Stack - None [2025-05-18 11:02:04:658 INFO] IPv4 supported, port: 19132: Used for gameplay and LAN discovery [2025-05-18 11:02:04:658 INFO] IPv6 supported, port: 19133: Used for gameplay [2025-05-18 11:02:04:856 INFO] Server started. [2025-05-18 11:02:04:860 INFO] ================ TELEMETRY MESSAGE =================== [2025-05-18 11:02:04:860 INFO] Server Telemetry is currently not enabled. [2025-05-18 11:02:04:860 INFO] Enabling this telemetry helps us improve the game. [2025-05-18 11:02:04:861 INFO] [2025-05-18 11:02:04:861 INFO] To enable this feature, add the line 'emit-server-telemetry=true' [2025-05-18 11:02:04:861 INFO] to the server.properties file in the handheld/src-server directory [2025-05-18 11:02:04:861 INFO] ======================================================

ignore the cannot open shared object file, it worked, so please @itzg add these two files to your docker image:

libjemalloc.so and libjemalloc.so.2, and now that problem won't happen anymore with me or someone else @stwalser if you are still in doubt about what to do.

kruonos avatar May 18 '25 14:05 kruonos

Thanks for finding that...but that sounds like a mess. Where am I going to have an arm64 distro image build pull x86 libraries? Those errors are annoying too. I'm going to be haunted by that with people sending me bug reports 😬

itzg avatar May 18 '25 16:05 itzg

I can send the files that I used, I got them from my x64_86 machine

kruonos avatar May 18 '25 16:05 kruonos

Thanks for the offer but I'm not going to source control and distribute a library. Instead it would need to be deterministically retrieved from an official distribution site.

I'll have to give this all some more thought. In the meantime you're welcome to build and use an image that addresses the issue.

itzg avatar May 18 '25 18:05 itzg

...and after a couple minutes thought it dawned on me to check the Debian libraries and I can simply apt install https://packages.debian.org/bookworm/libjemalloc2

itzg avatar May 18 '25 18:05 itzg

Can you re-pull and try out the latest image? I unable to verify the arm64 variant since there is a different box64 issue preventing my use on Mac OS.

itzg avatar May 18 '25 18:05 itzg

Not right now but when I'm at home I will try, also to check if it worked I used: watch -n 2 'ps -o pid,rss,vsz,cmd -p $(pgrep bedrock_server)' and read the linea to see if vsz and RSS was increasing

kruonos avatar May 18 '25 19:05 kruonos

I've got an somewhat similar issue, but I'm not sure if it is related or not. I'm running the bedrock server also on a VPS with Ampere A1 cores, in my case 3, equipped with 10 GB RAM. When only one player is connected to the server, everything is fine. With two players connected, it occasionally happens, and with three players it happens really often. What happens: Similar to like @kruonos described it, chunks or dimensions don't get rendered (sometimes the game shows a message, that the chunk is still being loaded and performance may 'slightly' be degraded, although slightly doesn't really nail it then 😅). Apart from that i noticed, that most of the times one player gets into a really weird state that I would describe as "shadow disconnected". By this I mean, that the player is unable to open its inventory, chests or interact with anything - but can move around. However, he isn't getting disconnected in terms of the client showing the corresponding error message and returning to the menu. When it that situation the player is attacked by a mob, he takes damage (or even dies), but the client does not see that (he learns it then when exiting and re-joining the game...). Usually, this for quite a while hits typically exactly the same player, so while not being entirely sure about it, I think that it most if not always affects the last one joining.

While that may also sound like a network issue, i don't think it is the case. I've analyzed the traffic multiple times with Wireshark, and the only thing I'm noticing, that the game stops to send some of the messages it usually sends to that one client. Also, any other communication happening between the client and the server simultaneously (which I've arranged for testing purposes once) is not affected. Because also memory consumption of the bedrock server doesn't look too high and the system has still plenty available, I've assumed that it may be a subtle error in box64 when it comes to handling multiple cores (or something similar). I can prevent the issue from occurring when i limit the Minecraft bedrock container to utilize only one core...though that's also not really a solution, because with 2 or at the latest 3 players performance gets terrible. But now reading this, I realize that it could still also be memory. In the log that gets printed when executing docker logs for that container, I do NOT see any errors like they were visible in the log here posted on May 18.

Is there any information I could provide to help?

max-4711 avatar Jul 09 '25 20:07 max-4711

This image just bundles standard packages and downloads the x86 binary from Mojang. I don't think there's much more I can do, but PRs are welcome if anyone can spot an image related change to improve.

itzg avatar Jul 09 '25 20:07 itzg