Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[Java] VectorUnloader has multiple memory leak issues

オープン
#1,234 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
62/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
静か
技術スタック
java
領域
data

調査の方向性

VectorUnloader クラスから始め、getRecordBatch() と appendNodes() に焦点を当てます。特に、issue で説明されている retain()、compress()、および再帰的な子処理のパスを確認してください。各箇所での失敗によって、以前の反復処理のバッファを含む、保持されているすべての ArrowBuf が解放されることを検証し、通常のレコードバッチのシリアライズが引き続き機能することを確認してください。

索引モデルが issue の本文から書いたものです。

説明

Type: bug
Describe the bug, including details regarding any error messages, version, and platform.
Problem Description

The VectorUnloader class has serious memory leak issues when serializing Vector data. Any exception thrown during the process will cause previously retained ArrowBuf instances to never be released.
Root Cause
ArrowBuf uses reference counting for memory management. After calling retain(), a corresponding release() must be called to free the buffer. The code has exception-safety defects in multiple locations:


Bug 1: OOM during compression causes leak
Location: appendNodes() method, around line 75
buf.getReferenceManager().retain();
buffers.add(codec.compress(vector.getAllocator(), buf)); // OOM here causes leak
Problem: If codec.compress() throws OutOfMemoryError, retain() has already been called but buffers.add() never executes, making the ArrowBuf unreleasable.

Bug 2: Compression failure in loop causes partial leak
Location: appendNodes() method, around lines 78-85
for (ArrowBuf buf : fieldBuffers) {
    buf.getReferenceManager().retain();
    buffers.add(codec.compress(vector.getAllocator(), buf)); // Any failure leaks all previously retained buffers
}
Problem: Any compression failure in the loop causes all previously retained buffers to leak.

Bug 3: Exception during recursive child vector processing causes leak
Location: appendNodes() method, around lines 87-89
for (FieldVector child : vector.getChildrenFromFields()) {
    appendNodes(child, nodes, buffers, variadicBufferCounts); // Exception here leaks buffers from current level
}
Problem: An exception during recursive child processing prevents release of buffers already retained at the current level.

Bug 4: Iteration failure in top-level loop causes cumulative leaks
Location: getRecordBatch() method, around lines 53-58
for (FieldVector vector : root.getFieldVectors()) {
    appendNodes(vector, nodes, buffers, variadicBufferCounts); // Any failure leaks all previously retained buffers
}
Problem: Each iteration retains buffers, and any failure causes cumulative leaks of all previously retained buffers. This is an accumulated leak.

Impact
  • All code using VectorUnloader.getRecordBatch()
  • Leak probability increases significantly when processing large datasets or when compressor runs low on memory
  • Leaked ArrowBuf instances persist until process termination
    Suggested Fix
  1. Use try-finally to ensure release() is called even when exceptions occur
  2. Or add buffers to the list before calling retain() and compress()
  3. Use transactional error handling for the entire getRecordBatch() operation, rolling back all buffers on failure
主要言語
Java
スター
95
フォーク
154
平均マージ
2日 10時間
マージ済み PR(30日)
11

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/arrow-java のほかの issue

apache/arrow-java の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。