junglechange opened a new issue, #37911:
URL: https://github.com/apache/arrow/issues/37911
### Describe the usage question you have. Please include as many useful
details as possible.
- arrow: 11.0.0
Running the following code results in the following error:
ERROR | 2023-09-27 23:53:55:393 | [main] memory.BaseAllocator
(BaseAllocator.java:436) - Memory was leaked by query. Memory leaked: (2)
Allocator(ROOT) 0/2/66562/9223372036854775807 (res/actual/peak/limit)
Exception in thread "main" java.lang.IllegalStateException: Memory was
leaked by query. Memory leaked: (2)
Allocator(ROOT) 0/2/66562/9223372036854775807 (res/actual/peak/limit)
at org.apache.arrow.memory.BaseAllocator.close(BaseAllocator.java:437)
at org.apache.arrow.memory.RootAllocator.close(RootAllocator.java:29)
```java
public static void main(String[] args) {
RootAllocator rootAllocator = new RootAllocator(Long.MAX_VALUE);
VectorSchemaRoot vectorSchemaRoot = listVectorSchemaRoot(rootAllocator);
vectorSchemaRoot.close();
rootAllocator.close();
}
public static VectorSchemaRoot listVectorSchemaRoot(BufferAllocator
bufferAllocator) {
ListVector listVector = ListVector.empty("list", bufferAllocator);
UnionListWriter listWriter = listVector.getWriter();
listWriter.allocate();
listWriter.start();
int listVectorCount = 1;
for (int i = 0; i < listVectorCount; i++) {
listWriter.setPosition(i);
listWriter.startList();
BaseWriter.StructWriter structWriter = listWriter.struct();
structWriter.start();
// structWriter.integer("code").writeInt(1); // use this,not memory leak
VarCharWriter codeWriter = structWriter.varChar("code");
writeString(bufferAllocator, codeWriter, "c" + i);
structWriter.end();
listWriter.endList();
}
listWriter.end();
listWriter.setValueCount(listVectorCount);
return new VectorSchemaRoot(Arrays.asList(listVector));
}
private static void writeString(BufferAllocator bufferAllocator,
VarCharWriter varCharWriter,
String string) {
byte[] bytes = string.getBytes(StandardCharsets.UTF_8);
ArrowBuf tmp = bufferAllocator.buffer(bytes.length);
tmp.setBytes(0, bytes);
varCharWriter.writeVarChar(0, bytes.length, tmp);
}
```
### Component(s)
Java
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]