Litematica (Forge)

Litematica (Forge)

336k Downloads

Out of memory error in singleplayer after multiplayer session when litematica is enabled

Fixer-007 opened this issue · 12 comments

commented

Minecraft version
1.15.2 / fabric 0.9.1-205

Mod version and malilib version
litematica-fabric-1.15.2-0.0.0-dev.20200515.184506
malilib-fabric-1.15.2-0.10.0-dev.21+arne.2

Description of the bug
I've noticed when litematica is enabled, if you switch from multiplayer world to singleplayer one a few times forth and back, you will end up with "Out of memory error" warning in minecraft itself preventing start of singleplayer world. Feels like memory is not freed or smth (since it takes several sessions back and forth to induce the error), not sure if it is exactly a litematica problem, but posting this report just to inform you.

RAM allocated is 1536mb, another big mod I use is voxelmap.

commented

Happening to me as well in 1.16.5.
I'm using Linux, running the game with MultiMC with 3 gb of RAM.

AdoptOpenJDK jdk-16.0.1+9-openj9

Fabric Loader 0.11.5
fabric-api-0.32.5+1.16

Mods:
[✔️] CraftPresence-Fabric-1.16.5-Release-1.7.6
[✔️] fabric-api-0.32.5+1.16
[✔️] iris-mc1.16.5-1.1.0+rev.64c239d
[✔️] lambdynamiclights-fabric-1.3.2+1.16.4
[✔️] lazydfu-0.1.3-SNAPSHOT
[✔️] litematica-fabric-1.16.4-0.0.0-dev.20210612.170003.jar
[✔️] lithium-fabric-mc1.16.5-0.6.4-SNAPSHOT
[✔️] malilib-fabric-1.16.4-0.10.0-dev.21+arne.5
[✔️] opticapes-1.0.0
[✔️] purityhud-fabric-1.16.4-0.19.0-dev.20210601.201816
[✔️] resolution-control-plus-2.0.1
[✔️] ShulkerTooltip-1.9.8
[✔️] sodium-fabric-mc1.16.5-0.2.0+IRIS3-rev.06c1968
[✔️] starlight-fabric-1.0.0-RC2-875359e
[✔️] Xaeros_Minimap_FP21.8.2_Fabric_1.16.5

---- Minecraft Crash Report ----
// Ouch. That hurt :(

Time: 7/14/21, 8:35 PM
Description: Rendering entity in world

java.lang.OutOfMemoryError: Cannot reserve 2098176 bytes of direct buffer memory (allocated: 2816598050, limit: 2818572288)
	at java.base/java.nio.Bits.reserveMemory(Bits.java:178)
	at java.base/java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:126)
	at java.base/java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:330)
	at net.minecraft.class_311.method_1596(class_311.java:18)
	at net.minecraft.class_287.ensureBufferCapacity(class_287.java:559)
	at me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriter.ensureCapacity(VertexBufferWriter.java:29)
	at net.minecraft.class_918.method_23180(class_918.java:572)
	...
commented

Does this happen when switching between the same server and just one single player world

Yes, I hop on to my creative testing sp world just to mock up some things and then connect back to server, I had that error countless times, after disabling litematica it does not occur (at least have not yet for several days and many rejoins).

In singleplayer world I have no loaded schematics, but on multiplayer one I have 226kbyte one (rendering disabled).

My full mod list on MultiMC:
BlockMeter-1.15-fabric0.4.23-1.3.jar
durabilityviewer-1.15.2-fabric0.4.23-1.7.jar
fabric-api-0.10.8+build.310-1.15.jar
litematica-fabric-1.15.2-0.0.0-dev.20200515.184506.jar.disabled
malilib-fabric-1.15.2-0.10.0-dev.21+arne.2.jar
minihud-fabric-1.15.2-0.19.0-dev.20200427.222110.jar
modmenu-1.10.1+build.30.jar
mousewheelie-1.5.0+mc1.15.2.jar
okzoomer-2.1.4-1.15.2.jar
RoughlyEnoughItems-3.6.21.jar
staffofbuilding-1.1.0-1.15.2.jar
VoxelMap-1.9.26b_for_1.15.2.jar
worldedit-fabric-mc1.15.2-7.1.0.jar (happened before installing this too)
WorldEditCUI-1.15.2_02.jar (happened before installing this too)

I've reenabled litematica, went into my singleplayer world, then to usual multiplayer server, 30 sec later logout and back to singleplayer and got this error below.

Error:
зображення

Error log:

[main/FATAL]: Out of memory
java.lang.OutOfMemoryError: Direct buffer memory
	at java.nio.Bits.reserveMemory(Unknown Source) ~[?:1.8.0_60]
	at java.nio.DirectByteBuffer.<init>(Unknown Source) ~[?:1.8.0_60]
	at java.nio.ByteBuffer.allocateDirect(Unknown Source) ~[?:1.8.0_60]
	at net.minecraft.class_311.method_1596(class_311.java:18) ~[intermediary-minecraft-1.15.2-client.jar:?]
	at net.minecraft.class_287.<init>(class_287.java:47) ~[intermediary-minecraft-1.15.2-client.jar:?]
	at fi.dy.masa.litematica.render.schematic.BufferBuilderCache.<init>(BufferBuilderCache.java:18) ~[litematica-fabric-1.15.2-0.0.0-dev.20200515.184506.jar:?]
	at fi.dy.masa.litematica.render.schematic.ChunkRenderDispatcherLitematica.<init>(ChunkRenderDispatcherLitematica.java:63) ~[litematica-fabric-1.15.2-0.0.0-dev.20200515.184506.jar:?]
	at fi.dy.masa.litematica.render.schematic.WorldRendererSchematic.loadRenderers(WorldRendererSchematic.java:179) ~[litematica-fabric-1.15.2-0.0.0-dev.20200515.184506.jar:?]
	at fi.dy.masa.litematica.render.schematic.WorldRendererSchematic.setWorldAndLoadRenderers(WorldRendererSchematic.java:150) ~[litematica-fabric-1.15.2-0.0.0-dev.20200515.184506.jar:?]
	at fi.dy.masa.litematica.render.LitematicaRenderer.onSchematicWorldChanged(LitematicaRenderer.java:77) ~[litematica-fabric-1.15.2-0.0.0-dev.20200515.184506.jar:?]
	at fi.dy.masa.litematica.world.SchematicWorldHandler.recreateSchematicWorld(SchematicWorldHandler.java:39) ~[litematica-fabric-1.15.2-0.0.0-dev.20200515.184506.jar:?]
	at fi.dy.masa.litematica.event.WorldLoadListener.onWorldLoadPost(WorldLoadListener.java:25) ~[litematica-fabric-1.15.2-0.0.0-dev.20200515.184506.jar:?]
	at fi.dy.masa.malilib.event.WorldLoadHandler.onWorldLoadPost(WorldLoadHandler.java:88) ~[malilib-fabric-1.15.2-0.10.0-dev.21+arne.2.jar:?]
	at net.minecraft.class_634.handler$zbi000$onPostGameJoin(class_634.java:3905) ~[intermediary-minecraft-1.15.2-client.jar:?]
	at net.minecraft.class_634.method_11120(class_634.java:383) ~[intermediary-minecraft-1.15.2-client.jar:?]
	at net.minecraft.class_2678.method_11567(class_2678.java:83) ~[intermediary-minecraft-1.15.2-client.jar:?]
	at net.minecraft.class_2678.method_11054(class_2678.java:13) ~[intermediary-minecraft-1.15.2-client.jar:?]
	at net.minecraft.class_2600.method_11072(class_2600.java:21) ~[intermediary-minecraft-1.15.2-client.jar:?]
	at net.minecraft.class_1255.method_18859(class_1255.java:144) ~[intermediary-minecraft-1.15.2-client.jar:?]
	at net.minecraft.class_4093.method_18859(class_4093.java:23) ~[intermediary-minecraft-1.15.2-client.jar:?]
	at net.minecraft.class_1255.method_16075(class_1255.java:118) ~[intermediary-minecraft-1.15.2-client.jar:?]
	at net.minecraft.class_1255.method_5383(class_1255.java:103) ~[intermediary-minecraft-1.15.2-client.jar:?]
	at net.minecraft.class_310.method_1523(class_310.java:956) ~[intermediary-minecraft-1.15.2-client.jar:?]
	at net.minecraft.class_310.method_1514(class_310.java:619) [intermediary-minecraft-1.15.2-client.jar:?]
	at net.minecraft.client.main.Main.main(Main.java:204) [intermediary-minecraft-1.15.2-client.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_60]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_60]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_60]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_60]
	at net.fabricmc.loader.game.MinecraftGameProvider.launch(MinecraftGameProvider.java:192) [fabric-loader-0.9.1+build.205.jar:?]
	at net.fabricmc.loader.launch.knot.Knot.init(Knot.java:140) [fabric-loader-0.9.1+build.205.jar:?]
	at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:26) [fabric-loader-0.9.1+build.205.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_60]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_60]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_60]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_60]
	at org.multimc.onesix.OneSixLauncher.launchWithMainClass(OneSixLauncher.java:196) [NewLaunch.jar:?]
	at org.multimc.onesix.OneSixLauncher.launch(OneSixLauncher.java:231) [NewLaunch.jar:?]
	at org.multimc.EntryPoint.listen(EntryPoint.java:143) [NewLaunch.jar:?]
	at org.multimc.EntryPoint.main(EntryPoint.java:34) [NewLaunch.jar:?]
commented

try to set your allowed memory to allow use around 3-4GB

commented

Does this happen when switching between the same server and just one single player world, ie. just between two different worlds? I would need to know how to try to reproduce it. I think I tried a while back just logging in and out of the same single player world repeatedly, and didn't manage to get any significant increase in memory usage that way.

commented

EDIT: I've figured out how to reliably reproduce this error. I created a new 1.16.2 Fabric instance in MultiMC, added Litematica, and added my localhost server to the multiplayer servers menu. Join the localhost server and create a schematic placement. Quit the game and rejoin. Then quit the game and rejoin again. You'll be greeted with the out of memory error. @maruohon

EDIT 2: Here's the schematic I used. It's taken from ilmango's 4-type TNT tree farm world download (the one that supports acacia, not jungle).


I can confirm this is still present in 1.16.2, litematica-fabric-1.16.2-0.0.0-dev.20200824.031346. However, this does not necessarily happen only when switching to a single-player world. For me it happens when I switch between two multiplayer servers, one of which contains a loaded schematic.

[12:45:37] [main/INFO]: Loading for game Minecraft 1.16.2

[13:20:20] [main/INFO]: Connecting to [redacted]
[13:21:48] [main/INFO]: [STDOUT]: Quitting server.

[13:25:42] [main/INFO]: Connecting to [redacted]
[13:32:36] [main/INFO]: [STDOUT]: Quitting server.

[18:14:03] [main/INFO]: Connecting to localhost, 25565
[18:18:43] [main/INFO]: [STDOUT]: Quitting server.

[20:46:07] [main/INFO]: Connecting to localhost, 25565
[20:46:09] [main/INFO]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', name='PROD'
[20:46:10] [main/FATAL]: Out of memory
java.lang.OutOfMemoryError: Cannot reserve 8388608 bytes of direct buffer memory (allocated: 4292218270, limit: 4294967296)
	at java.nio.Bits.reserveMemory(Bits.java:178) ~[?:?]
	at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:120) ~[?:?]
	at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:329) ~[?:?]
	at net.minecraft.class_311.method_1596(class_311.java:18) ~[intermediary-fabric-loader-0.9.2+build.206-1.16.2.jar:?]
	at net.minecraft.class_287.<init>(class_287.java:91) ~[intermediary-fabric-loader-0.9.2+build.206-1.16.2.jar:?]
	at fi.dy.masa.litematica.render.schematic.BufferBuilderCache.<init>(BufferBuilderCache.java:18) ~[litematica-fabric-1.16.2-0.0.0-dev.20200824.031346.jar:?]
	at fi.dy.masa.litematica.render.schematic.ChunkRenderDispatcherLitematica.<init>(ChunkRenderDispatcherLitematica.java:63) ~[litematica-fabric-1.16.2-0.0.0-dev.20200824.031346.jar:?]
	at fi.dy.masa.litematica.render.schematic.WorldRendererSchematic.loadRenderers(WorldRendererSchematic.java:179) ~[litematica-fabric-1.16.2-0.0.0-dev.20200824.031346.jar:?]
	at fi.dy.masa.litematica.render.schematic.WorldRendererSchematic.setWorldAndLoadRenderers(WorldRendererSchematic.java:150) ~[litematica-fabric-1.16.2-0.0.0-dev.20200824.031346.jar:?]
	at fi.dy.masa.litematica.render.LitematicaRenderer.onSchematicWorldChanged(LitematicaRenderer.java:78) ~[litematica-fabric-1.16.2-0.0.0-dev.20200824.031346.jar:?]
	at fi.dy.masa.litematica.world.SchematicWorldHandler.recreateSchematicWorld(SchematicWorldHandler.java:39) ~[litematica-fabric-1.16.2-0.0.0-dev.20200824.031346.jar:?]
	at fi.dy.masa.litematica.event.WorldLoadListener.onWorldLoadPost(WorldLoadListener.java:25) ~[litematica-fabric-1.16.2-0.0.0-dev.20200824.031346.jar:?]
	at fi.dy.masa.malilib.event.WorldLoadHandler.onWorldLoadPost(WorldLoadHandler.java:88) ~[malilib-fabric-1.16.2-0.10.0-dev.21+arne.1.jar:?]
	at net.minecraft.class_634.handler$zfa000$onPostGameJoin(class_634.java:3950) ~[intermediary-fabric-loader-0.9.2+build.206-1.16.2.jar:?]
	at net.minecraft.class_634.method_11120(class_634.java:411) ~[intermediary-fabric-loader-0.9.2+build.206-1.16.2.jar:?]
	at net.minecraft.class_2678.method_11567(class_2678.java:110) ~[intermediary-fabric-loader-0.9.2+build.206-1.16.2.jar:?]
	at net.minecraft.class_2678.method_11054(class_2678.java:18) ~[intermediary-fabric-loader-0.9.2+build.206-1.16.2.jar:?]
	at net.minecraft.class_2600.lambda$checkThreadAndEnqueue$0(class_2600.java:34) ~[intermediary-fabric-loader-0.9.2+build.206-1.16.2.jar:?]
	at net.minecraft.class_1255.method_18859(class_1255.java:172) ~[intermediary-fabric-loader-0.9.2+build.206-1.16.2.jar:?]
	at net.minecraft.class_4093.method_18859(class_4093.java:23) ~[intermediary-fabric-loader-0.9.2+build.206-1.16.2.jar:?]
	at net.minecraft.class_1255.method_16075(class_1255.java:134) ~[intermediary-fabric-loader-0.9.2+build.206-1.16.2.jar:?]
	at net.minecraft.class_1255.method_5383(class_1255.java:115) ~[intermediary-fabric-loader-0.9.2+build.206-1.16.2.jar:?]
	at net.minecraft.class_310.method_1523(class_310.java:990) ~[intermediary-fabric-loader-0.9.2+build.206-1.16.2.jar:?]
	at net.minecraft.class_310.method_1514(class_310.java:656) [intermediary-fabric-loader-0.9.2+build.206-1.16.2.jar:?]
	at net.minecraft.client.main.Main.main(Main.java:215) [intermediary-fabric-loader-0.9.2+build.206-1.16.2.jar:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:564) ~[?:?]
	at net.fabricmc.loader.game.MinecraftGameProvider.launch(MinecraftGameProvider.java:192) [fabric-loader-0.9.2+build.206.jar:?]
	at net.fabricmc.loader.launch.knot.Knot.init(Knot.java:140) [fabric-loader-0.9.2+build.206.jar:?]
	at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:26) [fabric-loader-0.9.2+build.206.jar:?]
commented

As @bermudalocket mentioned, I can confirm it can be reproduced by rejoining the same server a few times and has nothing to do with singleplayer specifically. It appears that with every rejoin to the server a buffer is being filled without being cleared. I have noticed FPS drops in game with each rejoin until lastly it crashes.

commented

I get the same error when logging out of a single player world, leaving the game on the title screen for a bit, and trying to log in again. In my mods folder I have fabric, itemscroller, litematica, malilib, minihud, optifabric, optifine and tweakeroo. They are all on MC version 1.16.3. The strange thing is that I have never created/used a schematic in this specific world.

[09:55:11] [main/FATAL]: Out of memory
java.lang.OutOfMemoryError: Direct buffer memory
	at java.nio.Bits.reserveMemory(Bits.java:658) ~[?:1.8.0_51]
	at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:123) ~[?:1.8.0_51]
	at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:311) ~[?:1.8.0_51]
	at net.minecraft.class_311.method_1596(class_311.java:18) ~[intermediary-fabric-loader-0.9.3+build.207-1.16.3.jar:?]
	at net.minecraft.class_287.<init>(class_287.java:91) ~[intermediary-fabric-loader-0.9.3+build.207-1.16.3.jar:?]
	at fi.dy.masa.litematica.render.schematic.BufferBuilderCache.<init>(BufferBuilderCache.java:18) ~[litematica-fabric-1.16.3-0.0.0-dev.20200913.215807.jar:?]
	at fi.dy.masa.litematica.render.schematic.ChunkRenderDispatcherLitematica.<init>(ChunkRenderDispatcherLitematica.java:63) ~[litematica-fabric-1.16.3-0.0.0-dev.20200913.215807.jar:?]
	at fi.dy.masa.litematica.render.schematic.WorldRendererSchematic.loadRenderers(WorldRendererSchematic.java:179) ~[litematica-fabric-1.16.3-0.0.0-dev.20200913.215807.jar:?]
	at fi.dy.masa.litematica.render.schematic.WorldRendererSchematic.setWorldAndLoadRenderers(WorldRendererSchematic.java:150) ~[litematica-fabric-1.16.3-0.0.0-dev.20200913.215807.jar:?]
	at fi.dy.masa.litematica.render.LitematicaRenderer.onSchematicWorldChanged(LitematicaRenderer.java:78) ~[litematica-fabric-1.16.3-0.0.0-dev.20200913.215807.jar:?]
	at fi.dy.masa.litematica.world.SchematicWorldHandler.recreateSchematicWorld(SchematicWorldHandler.java:39) ~[litematica-fabric-1.16.3-0.0.0-dev.20200913.215807.jar:?]
	at fi.dy.masa.litematica.event.WorldLoadListener.onWorldLoadPost(WorldLoadListener.java:25) ~[litematica-fabric-1.16.3-0.0.0-dev.20200913.215807.jar:?]
	at fi.dy.masa.malilib.event.WorldLoadHandler.onWorldLoadPost(WorldLoadHandler.java:88) ~[malilib-fabric-1.16.3-0.10.0-dev.21+arne.1.jar:?]
	at net.minecraft.class_634.handler$zdc000$onPostGameJoin(class_634.java:3950) ~[intermediary-fabric-loader-0.9.3+build.207-1.16.3.jar:?]
	at net.minecraft.class_634.method_11120(class_634.java:411) ~[intermediary-fabric-loader-0.9.3+build.207-1.16.3.jar:?]
	at net.minecraft.class_2678.method_11567(class_2678.java:110) ~[intermediary-fabric-loader-0.9.3+build.207-1.16.3.jar:?]
	at net.minecraft.class_2678.method_11054(class_2678.java:18) ~[intermediary-fabric-loader-0.9.3+build.207-1.16.3.jar:?]
	at net.minecraft.class_2600.lambda$checkThreadAndEnqueue$0(class_2600.java:34) ~[intermediary-fabric-loader-0.9.3+build.207-1.16.3.jar:?]
	at net.minecraft.class_2600$$Lambda$4907/687211960.run(Unknown Source) ~[?:?]
	at net.minecraft.class_1255.method_18859(class_1255.java:172) ~[intermediary-fabric-loader-0.9.3+build.207-1.16.3.jar:?]
	at net.minecraft.class_4093.method_18859(class_4093.java:23) ~[intermediary-fabric-loader-0.9.3+build.207-1.16.3.jar:?]
	at net.minecraft.class_1255.method_16075(class_1255.java:134) ~[intermediary-fabric-loader-0.9.3+build.207-1.16.3.jar:?]
	at net.minecraft.class_1255.method_5383(class_1255.java:115) ~[intermediary-fabric-loader-0.9.3+build.207-1.16.3.jar:?]
	at net.minecraft.class_310.method_1523(class_310.java:990) ~[intermediary-fabric-loader-0.9.3+build.207-1.16.3.jar:?]
	at net.minecraft.class_310.method_1514(class_310.java:656) [intermediary-fabric-loader-0.9.3+build.207-1.16.3.jar:?]
	at net.minecraft.client.main.Main.main(Main.java:215) [intermediary-fabric-loader-0.9.3+build.207-1.16.3.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_51]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_51]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_51]
	at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_51]
	at net.fabricmc.loader.game.MinecraftGameProvider.launch(MinecraftGameProvider.java:192) [fabric-loader-0.9.3+build.207.jar:?]
	at net.fabricmc.loader.launch.knot.Knot.init(Knot.java:140) [fabric-loader-0.9.3+build.207.jar:?]
	at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:26) [fabric-loader-0.9.3+build.207.jar:?]
commented

I can reproduce the crash as well. Below is the error that I'm getting and also the mods that I was using at the time of the crash. From what I can tell, there is likely a memory leak somewhere either when disconnecting from a server or connecting to a new server (leaving / joining world respectively in singleplayer).

[03:30:27] [main/FATAL]: Out of memory
java.lang.OutOfMemoryError: Direct buffer memory
	at Not Enough Crashes deobfuscated stack trace.(1.16.5+build.5) ~[?:?]
	at java.nio.Bits.reserveMemory(Bits.java:694) ~[?:1.8.0_265]
	at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:123) ~[?:1.8.0_265]
	at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:311) ~[?:1.8.0_265]
	at net.minecraft.client.util.GlAllocationUtils.allocateByteBuffer(GlAllocationUtils:18) ~[?:?]
	at net.minecraft.client.render.BufferBuilder.<init>(BufferBuilder:47) ~[?:?]
	at fi.dy.masa.litematica.render.schematic.BufferBuilderCache.<init>(BufferBuilderCache.java:18) ~[litematica-fabric-1.16.4-0.0.0-dev.20210120.213004.jar:?]
	at fi.dy.masa.litematica.render.schematic.ChunkRenderDispatcherLitematica.<init>(ChunkRenderDispatcherLitematica.java:63) ~[litematica-fabric-1.16.4-0.0.0-dev.20210120.213004.jar:?]
	at fi.dy.masa.litematica.render.schematic.WorldRendererSchematic.loadRenderers(WorldRendererSchematic.java:182) ~[litematica-fabric-1.16.4-0.0.0-dev.20210120.213004.jar:?]
	at fi.dy.masa.litematica.render.schematic.WorldRendererSchematic.setWorldAndLoadRenderers(WorldRendererSchematic.java:153) ~[litematica-fabric-1.16.4-0.0.0-dev.20210120.213004.jar:?]
	at fi.dy.masa.litematica.render.LitematicaRenderer.onSchematicWorldChanged(LitematicaRenderer.java:77) ~[litematica-fabric-1.16.4-0.0.0-dev.20210120.213004.jar:?]
	at fi.dy.masa.litematica.world.SchematicWorldHandler.recreateSchematicWorld(SchematicWorldHandler.java:63) ~[litematica-fabric-1.16.4-0.0.0-dev.20210120.213004.jar:?]
	at fi.dy.masa.litematica.event.WorldLoadListener.onWorldLoadPost(WorldLoadListener.java:25) ~[litematica-fabric-1.16.4-0.0.0-dev.20210120.213004.jar:?]
	at fi.dy.masa.malilib.event.WorldLoadHandler.onWorldLoadPost(WorldLoadHandler.java:88) ~[malilib-fabric-1.16.4-0.10.0-dev.21+arne.2.jar:?]
	at net.minecraft.client.network.ClientPlayNetworkHandler.handler$zfl000$onPostGameJoin(ClientPlayNetworkHandler:3456) ~[?:?]
	at net.minecraft.client.network.ClientPlayNetworkHandler.onGameJoin(ClientPlayNetworkHandler:411) ~[?:?]
	at net.minecraft.network.packet.s2c.play.GameJoinS2CPacket.apply(GameJoinS2CPacket:110) ~[?:?]
	at net.minecraft.network.packet.s2c.play.GameJoinS2CPacket.apply(GameJoinS2CPacket:18) ~[?:?]
	at net.minecraft.network.NetworkThreadUtils.method_11072(NetworkThreadUtils:21) ~[?:?]
	at net.minecraft.util.thread.ThreadExecutor.executeTask(ThreadExecutor:144) ~[?:?]
	at net.minecraft.util.thread.ReentrantThreadExecutor.executeTask(ReentrantThreadExecutor:23) ~[?:?]
	at net.minecraft.util.thread.ThreadExecutor.runTask(ThreadExecutor:118) ~[?:?]
	at net.minecraft.util.thread.ThreadExecutor.runTasks(ThreadExecutor:103) ~[?:?]
	at net.minecraft.client.MinecraftClient.render(MinecraftClient:1015) ~[?:?]
	at net.minecraft.client.MinecraftClient.run(MinecraftClient:681) ~[?:?]
	at net.minecraft.client.main.Main.main(Main:215) [intermediary-minecraft-1.16.5-client.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_265]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_265]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_265]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_265]
	at net.fabricmc.loader.game.MinecraftGameProvider.launch(MinecraftGameProvider.java:226) [fabric-loader-0.11.2.jar:?]
	at net.fabricmc.loader.launch.knot.Knot.launch(Knot.java:146) [fabric-loader-0.11.2.jar:?]
	at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:28) [fabric-loader-0.11.2.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_265]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_265]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_265]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_265]
	at org.multimc.onesix.OneSixLauncher.launchWithMainClass(OneSixLauncher.java:196) [NewLaunch.jar:?]
	at org.multimc.onesix.OneSixLauncher.launch(OneSixLauncher.java:231) [NewLaunch.jar:?]
	at org.multimc.EntryPoint.listen(EntryPoint.java:143) [NewLaunch.jar:?]
	at org.multimc.EntryPoint.main(EntryPoint.java:34) [NewLaunch.jar:?]
Mods:
  [✔️] attribute-fix-fabric-1.0.1
  [✔️] carpet-extra-1.16.5-1.4.27
  [✔️] clientcommands-2.4.10
  [❌] clientcommands-2.4.9.jar (disabled)
  [✔️] DisableCustomWorldsAdvice-1.2
  [✔️] fabric-api-0.31.0+1.16
  [❌] fabric-carpet-1.16.5-1.4.28+v210224.jar (disabled)
  [✔️] fabric-carpet-1.16.5-1.4.35+v210505
  [✔️] itemscroller-fabric-1.16.4-0.15.0-dev.20210111.205029
  [✔️] litematica-fabric-1.16.4-0.0.0-dev.20210120.213004
  [✔️] lithium-fabric-mc1.16.5-0.6.4
  [✔️] malilib-fabric-1.16.4-0.10.0-dev.21+arne.2
  [✔️] minihud-fabric-1.16.4-0.19.0-dev.20201103.184029
  [✔️] modmenu-1.16.8
  [✔️] NoFog-1.16.2b1-Fabric
  [❌] notenoughcrashes-3.1.7-fabric.jar (disabled)
  [✔️] notenoughcrashes-3.2.0-fabric
  [✔️] phosphor-fabric-mc1.16.3-0.7.1+build.11
  [✔️] shulkerboxtooltip-2.3.5+1.16.5
  [✔️] tweakeroo-fabric-1.16.4-0.10.0-dev.20210209.145902
  [❌] Xaeros_Minimap_21.4.1_Fabric_1.16.5.jar (disabled)
  [❌] Xaeros_Minimap_21.4.2_Fabric_1.16.5.jar (disabled)
  [❌] Xaeros_Minimap_21.4.3.1_Fabric_1.16.5.jar (disabled)
  [✔️] Xaeros_Minimap_21.5.0_Fabric_1.16.5
  [❌] XaerosWorldMap_1.12.1_Fabric_1.16.5.jar (disabled)
  [❌] XaerosWorldMap_1.12.2_Fabric_1.16.5.jar (disabled)
  [✔️] XaerosWorldMap_1.13.1_Fabric_1.16.5
commented

I have also been able to reproduce the crash fairly consistently as well. Below is the error and the list of mods I was using at the time of the crash. I have been able to get the crash to occur by just joining the same world a few times, but in this case I joined different worlds until it quickly ran out of memory. This is also happening to me regardless of if there are any schematics loaded or in the schematics directory.

java.lang.OutOfMemoryError: Direct buffer memory
	at Not Enough Crashes deobfuscated stack trace.(1.16.5+build.9) ~[?:?]
	at java.nio.Bits.reserveMemory(Bits.java:704) ~[?:1.8.0_292]
	at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:128) ~[?:1.8.0_292]
	at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:311) ~[?:1.8.0_292]
	at net.minecraft.client.util.GlAllocationUtils.allocateByteBuffer(GlAllocationUtils:18) ~[?:?]
	at net.minecraft.client.render.BufferBuilder.<init>(BufferBuilder:47) ~[?:?]
	at fi.dy.masa.litematica.render.schematic.BufferBuilderCache.<init>(BufferBuilderCache.java:18) ~[litematica-fabric-1.16.4-0.0.0-dev.20210420.200000.jar:?]
	at fi.dy.masa.litematica.render.schematic.ChunkRenderDispatcherLitematica.<init>(ChunkRenderDispatcherLitematica.java:63) ~[litematica-fabric-1.16.4-0.0.0-dev.20210420.200000.jar:?]
	at fi.dy.masa.litematica.render.schematic.WorldRendererSchematic.loadRenderers(WorldRendererSchematic.java:182) ~[litematica-fabric-1.16.4-0.0.0-dev.20210420.200000.jar:?]
	at fi.dy.masa.litematica.render.schematic.WorldRendererSchematic.setWorldAndLoadRenderers(WorldRendererSchematic.java:153) ~[litematica-fabric-1.16.4-0.0.0-dev.20210420.200000.jar:?]
	at fi.dy.masa.litematica.render.LitematicaRenderer.onSchematicWorldChanged(LitematicaRenderer.java:77) ~[litematica-fabric-1.16.4-0.0.0-dev.20210420.200000.jar:?]
	at fi.dy.masa.litematica.world.SchematicWorldHandler.recreateSchematicWorld(SchematicWorldHandler.java:63) ~[litematica-fabric-1.16.4-0.0.0-dev.20210420.200000.jar:?]
	at fi.dy.masa.litematica.event.WorldLoadListener.onWorldLoadPost(WorldLoadListener.java:25) ~[litematica-fabric-1.16.4-0.0.0-dev.20210420.200000.jar:?]
	at fi.dy.masa.malilib.event.WorldLoadHandler.onWorldLoadPost(WorldLoadHandler.java:89) ~[malilib-fabric-1.16.4-0.10.0-dev.21+arne.7.jar:?]
	at net.minecraft.client.network.ClientPlayNetworkHandler.handler$zha000$onPostGameJoin(ClientPlayNetworkHandler:3956) ~[?:?]
	at net.minecraft.client.network.ClientPlayNetworkHandler.onGameJoin(ClientPlayNetworkHandler:411) ~[?:?]
	at net.minecraft.network.packet.s2c.play.GameJoinS2CPacket.apply(GameJoinS2CPacket:110) ~[?:?]
	at net.minecraft.network.packet.s2c.play.GameJoinS2CPacket.apply(GameJoinS2CPacket:18) ~[?:?]
	at net.minecraft.network.NetworkThreadUtils.method_11072(NetworkThreadUtils:21) ~[?:?]
	at net.minecraft.class_2600$$Lambda$4154/0x0000000000000000.run(Unknown Source) ~[?:?]
	at net.minecraft.util.thread.ThreadExecutor.executeTask(ThreadExecutor:144) ~[?:?]
	at net.minecraft.util.thread.ReentrantThreadExecutor.executeTask(ReentrantThreadExecutor:23) ~[?:?]
	at net.minecraft.util.thread.ThreadExecutor.runTask(ThreadExecutor:118) ~[?:?]
	at net.minecraft.util.thread.ThreadExecutor.runTasks(ThreadExecutor:103) ~[?:?]
	at net.minecraft.client.MinecraftClient.render(MinecraftClient:1015) ~[?:?]
	at net.minecraft.client.MinecraftClient.run(MinecraftClient:681) ~[?:?]
	at net.minecraft.client.main.Main.main(Main:215) [intermediary-minecraft-1.16.5-client.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_292]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_292]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_292]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_292]
	at net.fabricmc.loader.game.MinecraftGameProvider.launch(MinecraftGameProvider.java:226) [fabric-loader-0.11.3.jar:?]
	at net.fabricmc.loader.launch.knot.Knot.launch(Knot.java:146) [fabric-loader-0.11.3.jar:?]
	at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:28) [fabric-loader-0.11.3.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_292]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_292]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_292]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_292]
	at org.multimc.onesix.OneSixLauncher.launchWithMainClass(OneSixLauncher.java:196) [NewLaunch.jar:?]
	at org.multimc.onesix.OneSixLauncher.launch(OneSixLauncher.java:231) [NewLaunch.jar:?]
	at org.multimc.EntryPoint.listen(EntryPoint.java:143) [NewLaunch.jar:?]
	at org.multimc.EntryPoint.main(EntryPoint.java:34) [NewLaunch.jar:?]
  [✔️] clientcommands-2.4.10
  [✔️] fabric-api-0.32.0+1.16
  [✔️] FastFurnace-1.16.4-4.4.0
  [✔️] ferritecore-2.0.4-fabric
  [❌] hydrogen-fabric-mc1.16.5-0.2.jar (disabled)
  [✔️] indium-1.0.0-modified
  [✔️] krypton-0.1.2
  [✔️] lazydfu-0.1.2
  [✔️] litematica-fabric-1.16.4-0.0.0-dev.20210420.200000
  [✔️] lithium-fabric-mc1.16.5-0.6.4
  [✔️] malilib-fabric-1.16.4-0.10.0-dev.21+arne.7
  [❌] mcvmcomputers-1.4.15.jar (disabled)
  [✔️] MinecraftCapes+Fabric+1.16.5-v10
  [✔️] minihud-fabric-1.16.4-0.19.0-dev.20210215.151117
  [✔️] modmenu-1.16.9
  [✔️] notenoughcrashes-3.2.0-fabric
  [✔️] okzoomer-4.0.1+1.16.2
  [✔️] randompatches-2.4.5-fabric
  [✔️] smoothboot-fabric-1.16.5-1.6.0
  [✔️] sodium-extra-0.3.0
  [❌] sodium-fabric-mc1.16.3-0.1.0.jar (disabled)
  [✔️] sodium-fabric-mc1.16.4-0.1.1-ipc2
  [✔️] starlight-fabric-1.0.0-RC2-1.16.x
  [✔️] tweakeroo-fabric-1.16.4-0.10.0-dev.20210419.180902
commented

Are you able to reproduce this crash using just the following mods on Minecraft 1.16.5?

  [✔️] fabric-api-0.32.0+1.16
  [✔️] litematica-fabric-1.16.4-0.0.0-dev.20210420.200000
  [✔️] malilib-fabric-1.16.4-0.10.0-dev.21+arne.7
commented

Yep!
Here's the log and the mods loaded:

[16:14:04] [main/FATAL]: Out of memory
java.lang.OutOfMemoryError: Direct buffer memory
	at java.nio.Bits.reserveMemory(Bits.java:704) ~[?:1.8.0_292]
	at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:128) ~[?:1.8.0_292]
	at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:311) ~[?:1.8.0_292]
	at net.minecraft.class_311.method_1596(class_311.java:18) ~[intermediary-minecraft-1.16.5-client.jar:?]
	at net.minecraft.class_287.<init>(class_287.java:47) ~[intermediary-minecraft-1.16.5-client.jar:?]
	at fi.dy.masa.litematica.render.schematic.BufferBuilderCache.<init>(BufferBuilderCache.java:18) ~[litematica-fabric-1.16.4-0.0.0-dev.20210420.200000.jar:?]
	at fi.dy.masa.litematica.render.schematic.ChunkRenderDispatcherLitematica.<init>(ChunkRenderDispatcherLitematica.java:63) ~[litematica-fabric-1.16.4-0.0.0-dev.20210420.200000.jar:?]
	at fi.dy.masa.litematica.render.schematic.WorldRendererSchematic.loadRenderers(WorldRendererSchematic.java:182) ~[litematica-fabric-1.16.4-0.0.0-dev.20210420.200000.jar:?]
	at fi.dy.masa.litematica.render.schematic.WorldRendererSchematic.setWorldAndLoadRenderers(WorldRendererSchematic.java:153) ~[litematica-fabric-1.16.4-0.0.0-dev.20210420.200000.jar:?]
	at fi.dy.masa.litematica.render.LitematicaRenderer.onSchematicWorldChanged(LitematicaRenderer.java:77) ~[litematica-fabric-1.16.4-0.0.0-dev.20210420.200000.jar:?]
	at fi.dy.masa.litematica.world.SchematicWorldHandler.recreateSchematicWorld(SchematicWorldHandler.java:63) ~[litematica-fabric-1.16.4-0.0.0-dev.20210420.200000.jar:?]
	at fi.dy.masa.litematica.event.WorldLoadListener.onWorldLoadPost(WorldLoadListener.java:25) ~[litematica-fabric-1.16.4-0.0.0-dev.20210420.200000.jar:?]
	at fi.dy.masa.malilib.event.WorldLoadHandler.onWorldLoadPost(WorldLoadHandler.java:89) ~[malilib-fabric-1.16.4-0.10.0-dev.21+arne.7.jar:?]
	at net.minecraft.class_634.handler$zdk000$onPostGameJoin(class_634.java:3956) ~[intermediary-minecraft-1.16.5-client.jar:?]
	at net.minecraft.class_634.method_11120(class_634.java:411) ~[intermediary-minecraft-1.16.5-client.jar:?]
	at net.minecraft.class_2678.method_11567(class_2678.java:110) ~[intermediary-minecraft-1.16.5-client.jar:?]
	at net.minecraft.class_2678.method_11054(class_2678.java:18) ~[intermediary-minecraft-1.16.5-client.jar:?]
	at net.minecraft.class_2600.method_11072(class_2600.java:21) ~[intermediary-minecraft-1.16.5-client.jar:?]
	at net.minecraft.class_2600$$Lambda$4154/0x0000000000000000.run(Unknown Source) ~[?:?]
	at net.minecraft.class_1255.method_18859(class_1255.java:144) ~[intermediary-minecraft-1.16.5-client.jar:?]
	at net.minecraft.class_4093.method_18859(class_4093.java:23) ~[intermediary-minecraft-1.16.5-client.jar:?]
	at net.minecraft.class_1255.method_16075(class_1255.java:118) ~[intermediary-minecraft-1.16.5-client.jar:?]
	at net.minecraft.class_1255.method_5383(class_1255.java:103) ~[intermediary-minecraft-1.16.5-client.jar:?]
	at net.minecraft.class_310.method_1523(class_310.java:1015) ~[intermediary-minecraft-1.16.5-client.jar:?]
	at net.minecraft.class_310.method_1514(class_310.java:681) [intermediary-minecraft-1.16.5-client.jar:?]
	at net.minecraft.client.main.Main.main(Main.java:215) [intermediary-minecraft-1.16.5-client.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_292]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_292]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_292]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_292]
	at net.fabricmc.loader.game.MinecraftGameProvider.launch(MinecraftGameProvider.java:226) [fabric-loader-0.11.3.jar:?]
	at net.fabricmc.loader.launch.knot.Knot.launch(Knot.java:146) [fabric-loader-0.11.3.jar:?]
	at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:28) [fabric-loader-0.11.3.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_292]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_292]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_292]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_292]
	at org.multimc.onesix.OneSixLauncher.launchWithMainClass(OneSixLauncher.java:196) [NewLaunch.jar:?]
	at org.multimc.onesix.OneSixLauncher.launch(OneSixLauncher.java:231) [NewLaunch.jar:?]
	at org.multimc.EntryPoint.listen(EntryPoint.java:143) [NewLaunch.jar:?]
	at org.multimc.EntryPoint.main(EntryPoint.java:34) [NewLaunch.jar:?]
Mods:
  [✔️] fabric-api-0.32.0+1.16
  [✔️] litematica-fabric-1.16.4-0.0.0-dev.20210420.200000
  [✔️] malilib-fabric-1.16.4-0.10.0-dev.21+arne.7

And a screenshot for good measure:
javaw_ASMSLGPS3y

commented

From what I tested, this kind of crash occurs even when the memory allocated is set to 4.5 GB on an 8 GB RAM system. Increasing the RAM allocation is unlikely to fully resolve the crash, only postpone it at best, suggesting that there is likely a memory leak related to the schematic world when you exit the world/leave the server (not game) and reconnect.