You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GH-55281: [C++][Gandiva] Release arena memory per row for any function with context #55281
Describe the bug, including details regarding any error messages, version, and platform.
Gandiva releases the arena after each row only if some function returns a string. has_arena_allocs_ is set only for binary-like return types in BuildFunctionCall.
levenshtein returns int32 but uses arena memory: (shorter_len + 1) * 2 * sizeof(int) bytes per row. In levenshtein(f0, f1) this memory is kept until Evaluate returns. In levenshtein(upper(f0), upper(f1)) it is released after each row.
To reproduce:
Make 262,144 rows, two utf8 columns, 16 chars each.
Build a projector with levenshtein(f0, f1).
Call Evaluate. Compare arrow::default_memory_pool()->total_bytes_allocated() before and after.
Expected: about 1 MB (the output buffers and one arena chunk).
Actual: 36,876,288 bytes. Memory grows with rows x string length. Results are correct. No crash.
Bigger batch, 2,097,152 rows of 64 chars: 1,178 MiB from the arena, peak RSS 1.6 GB.
Update: this also affects external functions. Any function that gets the execution context (kNeedsContext) can take arena memory. If it does not return a string, that memory is kept until the end of the batch. Test: an external C function that copies 64 bytes into the arena and returns int32. 262,144 rows: 17,858,560 bytes from the arena. Expected: about 1 MB.
changed the title [-][C++][Gandiva] Arena memory is not released per row when no function in the expression returns a string[/-][+]GH-55281: [C++][Gandiva] Release arena memory per row for any function with context[/+]on Oct 27, 2026
Activity
dmitry-chirkov-dremio commentedon Oct 27, 2026
take
dmitry-chirkov-dremio commentedon Oct 27, 2026
Side discovery from working on #55278
apacheGH-55281: [C++][Gandiva] Add regression test for levenshtein ar…
apacheGH-55281: [C++][Gandiva] Release arena memory per row for leven…
apacheGH-55281: [C++][Gandiva] Add arena tests for external and neste…
apacheGH-55281: [C++][Gandiva] Release arena memory per row for any f…
[-][C++][Gandiva] Arena memory is not released per row when no function in the expression returns a string[/-][+]GH-55281: [C++][Gandiva] Release arena memory per row for any function with context[/+]