harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikhail Markov (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-3148) [Classlib][nio] alloc many DirectByteBuffers may cause memory-out-error
Date Tue, 17 Apr 2007 10:31:15 GMT

    [ https://issues.apache.org/jira/browse/HARMONY-3148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12489353

Mikhail Markov commented on HARMONY-3148:

My fault - i've just reviewed the code of the fix without trying the unit test.
First of all, the call ByteBuffer.allocate() should be changed to ByteBuffer.allocateDirect(),
but even with the modified version the test does not fail for me (althouth it works much slower
than on RI).
Leo mentioned that he made some experiments (perhaps with another test case).
Leo, what tests did you experiment with?

Also, I've made some experiments with the testcase and surprisingly found that the test below
throws OOM on RI after several iterations but continues working on Harmony without OOM:
import java.nio.*;

public class Test {
    public static void main(String[] args) {
        final int CAPACITY = 0x800000; //8M
        ByteBuffer[] bufs = new ByteBuffer[1000];

        for (int i = 0; i < 1000; i++) {
            bufs[i] = ByteBuffer.allocateDirect(CAPACITY);
            System.out.println("Iteration: " + i);

So, It seems there are more serious problems in memory allocations for DirectBuffers.

> [Classlib][nio] alloc many DirectByteBuffers may cause memory-out-error
> -----------------------------------------------------------------------
>                 Key: HARMONY-3148
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3148
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Jimmy, Jing Lv
>         Assigned To: Tim Ellison
>         Attachments: patch-3148.zip
> Hi,
>      As discussed on mailing-list, DirectByteBuffer uses native memory which is out of
GC-control, alloc many DirectByteBuffer may cause memory-out-error if they are not GCed, even
they can be GCed at that time. 
>      This happens in Harmony but not in RI. This should be a bug of Harmony.
>      Note: other native memory users, e.g., java.util.zip.Deflater, may cause this problem
as well.

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

View raw message