db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knut Anders Hatlen (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DERBY-3731) Improve calculation of refSize in ClassSize.java
Date Fri, 20 Jun 2008 22:49:45 GMT

    [ https://issues.apache.org/jira/browse/DERBY-3731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12606927#action_12606927

Knut Anders Hatlen commented on DERBY-3731:

Not directly relevant for this issue, but I'm posting some
observations here so that they are not lost.

I used DTrace to check how much memory that was allocated in JDK 6 on
OpenSolaris 2008.05 and compared the results to what ClassSize would
estimate. I found these differences (assuming that refSize was
correctly set to 4 on 32-bit VMs and 8 on 64-bit VMs):

1) a better name for minObjectSize would be minArraySize, as it
attempts to estimate the fixed overhead for arrays

2) minObjectSize is set to 4*refSize (16 bytes on 32-bit, 32 bytes on
64-bit). The actual value is 3*refSize, but because of 8-byte word
boundaries the size of an empty array is refSize*3+4 == 4*refSize on
32-bit VMs (and the unused space can be exploited, so byte[0] and
byte[4] use the exact same number of bytes). On 64-bit VMs, 3*refSize
matches the word boundaries, so the correct value is 24 (and byte[1]
uses 8 more bytes than byte[0]).

3) booleanSize should be 1, not 4

4) charSize and shortSize should be 2, not 4

5) estimateBaseFromCoefficients() uses minObjectSize as the minimum
object size, whereas it actually is objectOverhead*refSize.

> Improve calculation of refSize in ClassSize.java 
> -------------------------------------------------
>                 Key: DERBY-3731
>                 URL: https://issues.apache.org/jira/browse/DERBY-3731
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>            Reporter: Kathey Marsden
>            Priority: Minor
>         Attachments: DERBY-3731_diff.txt
> java/engine/org/apache/derby/iapi/services/cache/ClassSize.java has a static code block
which calculates the size of a reference for the architecture.  This code could be improved
by adding garbage collection before measuring memory, to give a consistent  reading.     Also
there have been suggestions that we use os.arch or sun.arch.data.model to make the measurement
more reliable, especially on 64bit machines.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message