Skip to content

Commit 185440b

Browse files
authored
Clarify intent of Accountable#ramBytesUsed (#16000)
The memory tracking is meant for heap memory and not off-heap.
1 parent 6a0e461 commit 185440b

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

lucene/CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ Improvements
331331
* GITHUB#15989: DocValuesRangeIterator always tries to use skipper-based block iteration
332332
as its approximation. (Alan Woodward)
333333

334+
* GITHUB#16000: Clarify that Accountable#ramBytesUsed() reports JVM heap memory only. (Luca Cavanna)
335+
334336
Optimizations
335337
---------------------
336338
* GITHUB#15861: Optimise PhraseScorer by short circuiting non competitive documents in TOP_SCORES mode. (Prithvi S)

lucene/core/src/java/org/apache/lucene/util/Accountable.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,23 @@
2020
import java.util.Collections;
2121

2222
/**
23-
* An object whose RAM usage can be computed.
23+
* An object whose JVM heap memory usage can be computed.
24+
*
25+
* <p>Implementations should only account for memory allocated on the Java heap (i.e. memory managed
26+
* by the JVM garbage collector). Off-heap resources such as memory-mapped files or native direct
27+
* buffers should not be included; those should be tracked separately if needed (see e.g. {@link
28+
* org.apache.lucene.codecs.KnnVectorsReader#getOffHeapByteSize}).
2429
*
2530
* @lucene.internal
2631
*/
2732
public interface Accountable {
2833

29-
/** Return the memory usage of this object in bytes. Negative values are illegal. */
34+
/**
35+
* Returns an estimate of the JVM heap memory used by this object in bytes. The method name uses
36+
* "ram" for historical reasons; only JVM heap memory should be reported. Off-heap resources such
37+
* as memory-mapped files or native direct buffers should not be included. Negative values are
38+
* illegal.
39+
*/
3040
long ramBytesUsed();
3141

3242
/**

0 commit comments

Comments
 (0)