[JAVA] Leak in JdbcToArrowUtils
- Lenguaje dominante
- Java
- Estrellas
- 94
- Forks
- 152
- Merge medio
- 3 d 16 h
- PR fusionados (30 d)
- 11
Descripción
`JdbcToArrowUtils::updateVector(VarCharVector, String, boolean, int)` does not release the memory that it allocates for the `NullableVarCharHolder`. This can be verified by changing the first lines of `JdbcToArrowTest::testJdbcToArrowValues()` to the following:
```java
RootAllocator allocator = new RootAllocator(Integer.MAX_VALUE);
VectorSchemaRoot root = JdbcToArrow.sqlToArrow(conn, table.getQuery(), allocator, Calendar.getInstance());
testDataSets(root);
root.close();
assertEquals(allocator.getAllocatedMemory(), 0);
```
The leak can be fixed by closing the buffer in `updateVector`. However, I would propose to not use the `NullableVarCharHolder` in the first place because it creates an unnecessary copy of the string. Instead, I would use `BaseVariableWidthVector::setSafe(int index, byte[] value)` and `BaseVariableWidthVector::setNull(int index)` directly.
In addition, I would propose to check for leaks in JdbcToArrowTest.
I am willing to create a patch, so please let me know what approach is preferred.
**Reporter**: [Johannes Luong](https://issues.apache.org/jira/browse/ARROW-5536) / @jmaschad
**Note**: *This issue was originally created as [ARROW-5536](https://issues.apache.org/jira/browse/ARROW-5536). Please see the [migration documentation](https://github.com/apache/arrow/issues/14542) for further details.*
Guía de contribución
Línea de trabajo
Comienza en JdbcToArrowUtils::updateVector(VarCharVector, String, boolean, int) e inspecciona cómo NullableVarCharHolder asigna su búfer. Revisa JdbcToArrowTest::testJdbcToArrowValues() y añade la aserción de memoria del allocator mostrada en el issue; el trabajo estará terminado cuando el test pase con cero memoria asignada después de cerrar el root.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- java
- Área
- databases
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100