lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler (Commented) (JIRA)" <>
Subject [jira] [Commented] (LUCENE-3867) RamUsageEstimator.NUM_BYTES_ARRAY_HEADER is incorrect
Date Wed, 14 Mar 2012 15:02:46 GMT


Uwe Schindler commented on LUCENE-3867:

On Hotspot Mailing list some people also seem to have an idea about jRockit and IBM J9:

From: Krystal Mok [] 
Sent: Wednesday, March 14, 2012 3:46 PM
To: Uwe Schindler
Cc: Dawid Weiss; hotspot compiler
Subject: Re: How to detect if the VM is running with compact refs from within the VM (no agent)?


Just in case you'd care, the same MXBean could be used to detect compressed references on
JRockit, too. It's probably available starting from JRockit R28.

Instead of "UseCompressedOops", use "CompressedRefs" as the VM option name on JRockit.

Don't know how to extract this information for J9 without another whole bunch of hackeries...well,
you could try this, on a "best-effort" basis for platform detection:
IBM J9's VM version string contains the compressed reference information. Example:

$ export JAVA_OPTS='-Xcompressedrefs'
$ groovysh
Groovy Shell (1.7.7, JVM: 1.7.0)
Type 'help' or '\h' for help.
groovy:000> System.getProperty ''
===> JRE 1.7.0 Linux amd64-64 Compressed References 20110810_88604 (JIT enabled, AOT enabled)
J9VM - R26_Java726_GA_20110810_1208_B88592
JIT  - r11_20110810_20466
GC   - R26_Java726_GA_20110810_1208_B88592_CMPRSS
J9CL - 20110810_88604
groovy:000> quit

So grepping for "Compressed References" in the "" system property gives you the

- Kris
> RamUsageEstimator.NUM_BYTES_ARRAY_HEADER is incorrect
> -----------------------------------------------------
>                 Key: LUCENE-3867
>                 URL:
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: core/index
>            Reporter: Shai Erera
>            Assignee: Shai Erera
>            Priority: Trivial
>             Fix For: 3.6, 4.0
>         Attachments: LUCENE-3867-compressedOops.patch, LUCENE-3867.patch
> RamUsageEstimator.NUM_BYTES_ARRAY_HEADER is computed like that: NUM_BYTES_OBJECT_HEADER
+ NUM_BYTES_INT + NUM_BYTES_OBJECT_REF. The NUM_BYTES_OBJECT_REF part should not be included,
at least not according to this page:
> {quote}
> A single-dimension array is a single object. As expected, the array has the usual object
header. However, this object head is 12 bytes to accommodate a four-byte array length. Then
comes the actual array data which, as you might expect, consists of the number of elements
multiplied by the number of bytes required for one element, depending on its type. The memory
usage for one element is 4 bytes for an object reference ...
> {quote}
> While on it, I wrote a sizeOf(String) impl, and I wonder how do people feel about including
such helper methods in RUE, as static, stateless, methods? It's not perfect, there's some
room for improvement I'm sure, here it is:
> {code}
> 	/**
> 	 * Computes the approximate size of a String object. Note that if this object
> 	 * is also referenced by another object, you should add
> 	 * {@link RamUsageEstimator#NUM_BYTES_OBJECT_REF} to the result of this
> 	 * method.
> 	 */
> 	public static int sizeOf(String str) {
> 		return 2 * str.length() + 6 // chars + additional safeness for arrays alignment
> 				+ 3 * RamUsageEstimator.NUM_BYTES_INT // String maintains 3 integers
> 				+ RamUsageEstimator.NUM_BYTES_ARRAY_HEADER // char[] array
> 				+ RamUsageEstimator.NUM_BYTES_OBJECT_HEADER; // String object
> 	}
> {code}
> If people are not against it, I'd like to also add sizeOf(int[] / byte[] / long[] / double[]
... and String[]).

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message