Skip to content

Commit

Permalink
minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rongou committed Jan 6, 2022
1 parent 04c9e19 commit b2b62c0
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions java/src/main/java/ai/rapids/cudf/PinnedMemoryPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,7 @@ public final class PinnedMemoryPool implements AutoCloseable {
private static class SortedBySize implements Comparator<MemorySection> {
@Override
public int compare(MemorySection s0, MemorySection s1) {
int ret = Long.compare(s0.size, s1.size);
if (ret == 0) {
ret = Long.compare(s0.baseAddress, s1.baseAddress);
}
return ret;
return Long.compare(s0.size, s1.size);
}
}

Expand Down Expand Up @@ -287,11 +283,10 @@ private synchronized HostMemoryBuffer tryAllocateInternal(long bytes) {
.findFirst();
if (!firstFit.isPresent()) {
if (log.isDebugEnabled()) {
long largest = freeHeap.stream()
MemorySection largest = freeHeap.stream()
.max(new SortedBySize())
.orElse(new MemorySection(0, 0))
.size;
log.debug("Insufficient pinned memory. {} needed, {} found", alignedBytes, largest);
.orElse(new MemorySection(0, 0));
log.debug("Insufficient pinned memory. {} needed, {} found", alignedBytes, largest.size);
}
return null;
}
Expand All @@ -316,7 +311,8 @@ private synchronized HostMemoryBuffer tryAllocateInternal(long bytes) {
private synchronized void free(MemorySection section) {
log.debug("Freeing {} with {} outstanding {}", section, freeHeap, numAllocatedSections);
availableBytes += section.size;
for (Iterator<MemorySection> it = freeHeap.iterator(); it.hasNext(); ) {
Iterator<MemorySection> it = freeHeap.iterator();
while(it.hasNext()) {
MemorySection current = it.next();
if (section.canCombine(current)) {
it.remove();
Expand Down

0 comments on commit b2b62c0

Please sign in to comment.