fix: 修复内存泄漏(事件总线、缓存、小地图纹理重分配) - #182
Merged
Merged
Conversation
Bound or free GL/heap resources that could grow for a whole session: EventDispatcher identity unregister + dedupe, ItemModelLists/EntityCulling cleanup on Performance disable, MotionBlur FBO delete, MusicTextures LRU with deleteTexture, and clear static entity refs on disconnect. Co-authored-by: Gao Yu <gaoyu06@users.noreply.github.com>
bindTextureBuffer used glTexImage2D on every HUD frame (~0.75MB at 512² RGB). That orphans GPU pages at multi-GB/min when MiniMap is on. Allocate storage once (or on size change) and update with glTexSubImage2D. Co-authored-by: Gao Yu <gaoyu06@users.noreply.github.com>
Contributor
|
Cursor Agent can help with this pull request. Just |
Contributor
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
排查用户反馈「游玩约半小时内存涨到十几 GB」。
结论:先前若干会话级泄漏量级偏小;若小地图开启,每帧
glTexImage2D重分配地图纹理(约 0.75MB/帧)可单独解释该增速。当前生产包里 MiniMap 模块仍被临时注释,默认不走该路径,但代码路径仍需修好。改动
小地图(致命,开启时)
Minimap.bindTextureBuffer:尺寸变化时才glTexImage2D,平时改用glTexSubImage2D。EventDispatcher
按 listener 身份注销;同 listener+method 去重;
ClientSettings避免配置加载双重注册。Performance / ItemModelLists
关闭 CacheItemModels 或禁用模块时
invalidate();总会话 display list 上限 512;禁用时EntityCulling.reset()。MusicTextures
有界 LRU +
deleteTexture。其它
MotionBlur 禁用时删除静态 FBO;
DamageIndicator/TargetDisplay断线与禁用清理;TextRenderer.obfuscatedCache/Utility.messages有界。验证
./gradlew test(含EventDispatcherTest)./gradlew buildmain一致)。本地验证可临时modules.add(new MiniMap())。说明
默认关闭小地图时,十几 GB 仍需结合 MotionBlur New / OptiFine / 原版区块(F3+A)做堆 vs 进程分流。