Conversation
PeekOutput()で取得したテンソルをDisposeせずに放置していた問題を修正。 ## 修正内容 ### LLMRunner.cs - kvCache テンソル: 初回forward passで取得したKVキャッシュを即座にDispose - newKvCache テンソル: 自己回帰ループ内で毎回取得するKVキャッシュをDispose ### FlowRunner.cs - velocity テンソル: Euler ODEソルバーの各ステップで取得する速度場テンソルをDispose ## 原因 Unity AI Interface (Sentis) の `Worker.PeekOutput()` は内部バッファへの参照を返すが、 データをCPU側にコピー後、明示的にDisposeしないとメモリリークが発生する。 これにより `Found unreferenced, but undisposed CPUTensorData` 警告が出ていた。 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.
概要
Worker.PeekOutput()で取得したテンソルを適切にDisposeせず、メモリリークが発生していた問題を修正しました。変更内容
LLMRunner.cs
kvCacheテンソル: 初回forward passで取得したKVキャッシュを即座にDisposenewKvCacheテンソル: 自己回帰ループ内で毎回取得するKVキャッシュをDispose(最大500回/推論)FlowRunner.cs
velocityテンソル: Euler ODEソルバーの各ステップで取得する速度場テンソルをDispose(10回/推論)原因
Unity AI Interface (Sentis) の
Worker.PeekOutput()は内部バッファへの参照を返しますが、データをCPU側にコピーした後も明示的にDisposeしないとメモリリークが発生します。これにより
Found unreferenced, but undisposed CPUTensorData警告が出ていました。修正後の動作
usingステートメントを使用して、データコピー完了後に即座にDisposeするように変更テスト
🤖 Generated with Claude Code