josemmo / yamipa

Yet Another Minecraft Image Placing Addon

Home Page:https://www.spigotmc.org/resources/88709/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Clients use an excessive amount of memory

Leomelonseeds opened this issue · comments

commented

Hey there, I found that when placing a few animated gifs in my world, it happens that whenever a player goes near these gifs, the sheer amount of packets that must be sent causes upwards of 4GB of memory to be used client side. This causes clients to have extremely high ping for a few seconds, and in cases with bad internet may cause them to time out. Worse still, it seems that the used memory is never cleared, causing the memory to be used until the game is restarted.

After loading several gifs a few times, task manager shows:
image
even after the image goes out of render distance, the used memory sometimes is cleared after a while but in more cases stays as a memory leak.

For reference, I have 5 gifs that are loaded at once in a tutorial area. They can be found at https://imgur.com/a/vGgdvTy.

I was wondering if fixing this would be an optimization I should be making solely on my end, or if there were plugin-side optimizations that could be made to reduce the effect on clients.

Hello @Leomelonseeds,

That's because the GIF images you're using are too long (35 + 33 + 6 + 7 + 7 = 88 seconds) and Yamipa is not designed with this goal in mind. Assuming each image is 3x2 blocks in size (768x256 pixels) and given each pixel takes a byte of network traffic to be sent, that's 768 x 256 = 196,608 bytes per frame. 88 seconds at 50ms GIF delay (playback speed) translates to 1,760 frames in total. Putting all together, that's 346 MB.

The ping thing I can understand, your server is sending 346 MB of traffic every time a new player goes near that GIF area. What I don't know is how you can get from 346 MB to 4 GB, that's way too much memory usage.

What server are you using? How did you measure memory usage? Is this allocated memory by the JVM or in-use memory?

commented

Hey, thanks for getting back to me. Looks like I forgot to include the dimensions of my gifs at 7x4, which would bring the size to 770MB following the math. I will definitely have to optimize these gifs on my end.

As for memory usage, the server-side seems to do just fine handling sending the packets to the client with no noticable changes in memory usage (i.e. no memory leaks) using /mem ingame or htop on my dedicated host. It's the client that suffers - on my home PC, I can teleport to the area and watch my Java memory usage go up by multiple gigabytes through Task Manager as the gifs play. Curiously, the allocated memory that can be seen on the F3 screen doesn't seem to change accordingly, the increased memory can only be seen in Task Manager, and will freeze my PC and eventually crash Minecraft when too many gifs are loaded.

Closing this issue as there's nothing more I can do.

As you say, the server (which is where Yamipa runs) is doing fine. Minecraft client is not designed to receive this many item frames, so unless Mojang makes some changes to the client, there's not much else to do.