Skip to content

[Java] DictionaryProvider leaks memory while adding dictionaries with duplicate encoding #313

Description

@asfimport

DictionaryProvider leaks memory while adding dictionaries with duplicate encoding. Is this expected? Should the provider release the memory of the existing dictionary vector if it accepts another one with same encoding id ?

Sample code:

"dictionaryProvider"should" not leak memory while adding dictionaries with duplicate encoding"in {
valallocator: RootAllocator = newRootAllocator()
valvector: ListVector = ListVector.empty("vector", allocator)
valdictionaryVector1: ListVector = ListVector.empty("dict1", allocator)
valdictionaryVector2: ListVector = ListVector.empty("dict2", allocator)
valwriter1: UnionListWriter = vector.getWriterwriter1.allocatewriter1.setValueCount(1)
valdictWriter1: UnionListWriter = dictionaryVector1.getWriterdictWriter1.allocatedictWriter1.setValueCount(1)
valdictWriter2: UnionListWriter = dictionaryVector2.getWriterdictWriter2.allocatedictWriter2.setValueCount(1)
valdictionary1: Dictionary = newDictionary(dictionaryVector1, newDictionaryEncoding(1L, false, None.orNull))
valdictionary2: Dictionary = newDictionary(dictionaryVector2, newDictionaryEncoding(1L, false, None.orNull))
valprovider = newDictionaryProvider.MapDictionaryProviderprovider.put(dictionary1)
provider.put(dictionary2)
vector.clear()
provider.getDictionaryIds.asScala.map(id => provider.lookup(id).getVector.clear())
allocator.getAllocatedMemoryshouldBe0
} 

Reporter: Vimal Varghese

Note: This issue was originally created as ARROW-16920. Please see the migration documentation for further details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions