Skip to content

Commit

Permalink
fix: Deallocate row addresses and size arrays after exporting (apache…
Browse files Browse the repository at this point in the history
…#246)

When we export row addresses and sizes to native, they are copied to separate arrays. We should deallocate array buffers after exporting them to reduce memory allocation.
  • Loading branch information
viirya authored Apr 7, 2024
1 parent e358c16 commit 8a512ba
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,17 @@ class RowPartition(initialSize: Int) {

def getNumRows: Int = rowAddresses.size

def getRowAddresses: Array[Long] = rowAddresses.toArray
def getRowSizes: Array[Int] = rowSizes.toArray
def getRowAddresses: Array[Long] = {
val array = rowAddresses.toArray
rowAddresses = null
array
}

def getRowSizes: Array[Int] = {
val array = rowSizes.toArray
rowSizes = null
array
}

def reset(): Unit = {
rowAddresses = new ArrayBuffer[Long](initialSize)
Expand Down

0 comments on commit 8a512ba

Please sign in to comment.