dweiss commented on a change in pull request #1917:
URL: https://github.com/apache/lucene-solr/pull/1917#discussion_r494311008
##########
File path:
lucene/core/src/java/org/apache/lucene/store/ByteBuffersDataOutput.java
##########
@@ -400,8 +400,13 @@ public void writeSetOfStrings(Set<String> set) {
public long ramBytesUsed() {
// Return a rough estimation for allocated blocks. Note that we do not make
// any special distinction for direct memory buffers.
- return RamUsageEstimator.NUM_BYTES_OBJECT_REF * blocks.size() +
- blocks.stream().mapToLong(buf -> buf.capacity()).sum();
+ ByteBuffer first = blocks.peek();
+ if (first == null) {
+ return 0L;
+ } else {
+ // All blocks have the same capacity.
Review comment:
Hmmm... Do they? I don't think this is the case, in general, since you
can plug in an arbitrary block provider/ recycler?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]