I don't know why but my server crashed due to RAM overflown

It has happened multiple time, and only when I use ABSOLUTELY nothing (Paper 1.21.11, no plugins, yes datapacks (2)) then it didn't happen BUT reached 3.7gb if I add 2-5 plugins it INSTANTLY shoots to 4.3-4.4gb and idles there. Forcing me to kill the process in order to shut dow…

...
error='Not enough space' (errno=12)
# There is insufficient memory for the Java Runtime Environment to continue.
...
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 65536 bytes. Error detail: committing reserved memory.
# Possible reasons:
#   The system is out of physical RAM or swap space
#   This process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap
# Possible solutions:
...
#  Out of Memory Error (os_linux.cpp:2829), pid=1, tid=164
# JRE version: OpenJDK Runtime Environment Temurin-21.0.10+7 (21.0.10+7) (build 21.0.10+7-LTS)
# Java VM: OpenJDK 64-Bit Server VM Temurin-21.0.10+7 (21.0.10+7-LTS, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Core dump will be written. Default location: core.1 (may not exist)
---------------  S U M M A R Y ------------
Command Line: -Xms512M -Xmx3072M server.jar
Host: x86_64, 32 cores, 250G, Linux
Time: Sun Apr 12 09:19:08 2026 UTC elapsed time: 185.706483 seconds (0d 0h 3m 5s)
---------------  T H R E A D  ---------------
Current thread (0x00007f076c27a4b0):  JavaThread "Paper I/O Worker #0" daemon [_thread_in_vm, id=164, stack(0x00007f0796aec000,0x00007f0796bec000) (1024K)]
Stack: [0x00007f0796aec000,0x00007f0796bec000],  sp=0x00007f0796be84c0,  free space=1009k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x100fac8]  (os_linux.cpp:2829)
V  [libjvm.so+0x101052d]
V  [libjvm.so+0x6bf77f]
V  [libjvm.so+0xd0a9f1]
V  [libjvm.so+0xd03fff]
V  [libjvm.so+0x100602e]
V  [libjvm.so+0xc7b741]
V  [libjvm.so+0x5ca7f1]
V  [libjvm.so+0x5ca9b7]
V  [libjvm.so+0xc7ea22]
V  [libjvm.so+0xc7ecdb]
V  [libjvm.so+0xc7de2a]
V  [libjvm.so+0x69cef5]
V  [libjvm.so+0x61beaf]
V  [libjvm.so+0x61c8ae]
V  [libjvm.so+0xb554ce]
V  [libjvm.so+0xf40271]
V  [libjvm.so+0x9fc740]
V  [libjvm.so+0x9fcb90]  JVM_LookupDefineClass+0x80
C  [libjava.so+0xf00b]  Java_java_lang_ClassLoader_defineClass0+0x14b
J 1563  java.lang.ClassLoader.defineClass0(Ljava/lang/ClassLoader;Ljava/lang/Class;Ljava/lang/String;[BIILjava/security/ProtectionDomain;ZILjava/lang/Object;)Ljava/lang/Class; java.base@21.0.10 (0 bytes) @ 0x00007f08dc469d22 [0x00007f08dc469bc0+0x0000000000000162]
J 29454 c2 java.lang.invoke.MethodHandles$Lookup$ClassDefiner.defineClass(ZLjava/lang/Object;)Ljava/lang/Class; java.base@21.0.10 (213 bytes) @ 0x00007f08dd1850ac [0x00007f08dd184f00+0x00000000000001ac]
J 3408 c1 java.lang.invoke.InvokerBytecodeGenerator.loadMethod([B)Ljava/lang/invoke/MemberName; java.base@21.0.10 (39 bytes) @ 0x00007f08d4e18f1c [0x00007f08d4e18d80+0x000000000000019c]
J 2174 c1 java.lang.invoke.InvokerBytecodeGenerator.generateCustomizedCode(Ljava/lang/invoke/LambdaForm;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/MemberName; java.base@21.0.10 (34 bytes) @ 0x00007f08d4bf2d3c [0x00007f08d4bf2b80+0x00000000000001bc]
J 2219 c1 java.lang.invoke.LambdaForm.compileToBytecode()V java.base@21.0.10 (164 bytes) @ 0x00007f08d4c0c8f4 [0x00007f08d4c0c700+0x00000000000001f4]
J 7083 c2 java.lang.invoke.BoundMethodHandle.(Ljava/lang/invoke/MethodType;Ljava/lang/invoke/LambdaForm;)V java.base@21.0.10 (32 bytes) @ 0x00007f08dcb76090 [0x00007f08dcb75f40+0x0000000000000150]
J 9249 c1 java.lang.invoke.BoundMethodHandle$Species_L.copyWith(Ljava/lang/invoke/MethodType;Ljava/lang/invoke/LambdaForm;)Ljava/lang/invoke/BoundMethodHandle; java.base@21.0.10 (14 bytes) @ 0x00007f08d4f81674 [0x00007f08d4f81540+0x0000000000000134]
J 8756 c1 java.lang.invoke.MethodHandles.dropArgumentsTrusted(Ljava/lang/invoke/MethodHandle;I[Ljava/lang/Class;)Ljava/lang/invoke/MethodHandle; java.base@21.0.10 (111 bytes) @ 0x00007f08d4e7a984 [0x00007f08d4e7a200+0x0000000000000784]
J 12794 c1 java.lang.invoke.StringConcatFactory.generateMHInlineCopy(Ljava/lang/invoke/MethodType;[Ljava/lang/String;)Ljava/lang/invoke/MethodHandle; java.base@21.0.10 (497 bytes) @ 0x00007f08d5915154 [0x00007f08d5913780+0x00000000000019d4]
J 12793 c1 java.lang.invoke.StringCo

It has happened multiple time, and only when I use ABSOLUTELY nothing (Paper 1.21.11, no plugins, yes datapacks (2)) then it didn't happen BUT reached 3.7gb if I add 2-5 plugins it INSTANTLY shoots to 4.3-4.4gb and idles there. Forcing me to kill the process in order to shut down. also before I just remove everything (still have a lot of plugins and datapacks, the server behaved normally but slowly building up RAM and spark also returned nothing useful (or I don't know how to read) Any solutions ;-;

All boards