Grasscutter icon indicating copy to clipboard operation
Grasscutter copied to clipboard

[Bug] Memory leak 内存泄露

Open HongchengQ opened this issue 10 months ago • 4 comments

Each player occupies a significant amount of memory in this program. This is a server that has been running for 10 hours. Prior to this, the online player count remained between 10 and 30. When players exit the game, the server does not clean up the corresponding memory, resulting in excessive memory usage even when there are only two players left on the server. This is even crazier than GIO.

每一名玩家在这个程序上占用的内存都非常多 这是一个开了10个小时的服务端 在这之前在线人数保持在10-30之间 当人们退出游戏时服务端并不会清理掉对应的内存 使得即使最后服务端只有两名玩家 内存占用也非常离谱 这简直比gio还要疯狂

屏幕截图 2024-03-31 202752

HongchengQ avatar Mar 31 '24 16:03 HongchengQ

我使用vvm观察发现内存占用会随着玩家的进入而越来越多 似乎总有一部分内存不会被清理 但这不是gc崩溃最主要的原因 每次gc崩溃都会发生线程死锁 在线程死锁之前程序占用的内存会达到历史最高点 然后cpu占用几乎会占用到百分百 最后发生线程死锁 玩家进入游戏白屏

HongchengQ avatar Aug 14 '24 16:08 HongchengQ

I observed using vvm that memory usage increases as more players enter the game, and it seems that a portion of the memory is not being cleaned up. However, this isn't the primary cause of GC crashes. Before each GC crash, there's a thread deadlock, which occurs after the program reaches its highest historical memory usage point. This is followed by near 100% CPU usage, leading to a thread deadlock. Players then experience a white screen when entering the game.

HongchengQ avatar Aug 14 '24 16:08 HongchengQ

以及在程序启动后第一个玩家进入游戏时也有概率发生线程死锁 这在还没有合并unstable分支前是不会发生的 Additionally, there's a chance of a thread deadlock happening when the first player enters the game after the program starts. This did not occur before the unstable branch was merged.

HongchengQ avatar Aug 14 '24 16:08 HongchengQ