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] Updated: (HARMONY-3148) [Classlib][nio] alloc many DirectByteBuffers may cause memory-out-error
Date Thu, 17 May 2007 14:37:17 GMT

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

Mikhail Markov updated HARMONY-3148:
------------------------------------

    Attachment: H-3148_2.patch

Sorry Leo, i've almost prepared the patch when read  your message :-).
This is the refactored patch based on the original one.

The changes are the following:
1) Platform-dependent part is moved to portlib (as Mark suggested)
2) In addition to default method with no params the method with 2 parameters is added to be
able to customize the thresholds: used memory threshold (in %) and available memory threshold
3) Fixed Windows version by adding "stat.dwLength = sizeof (stat);" line
4) Fixed Linux version :-) as sysinfo() according to doc, returns the structure containing
various values in memory units starting from 2.3.23 kernel version for X86, so to get proper
value in bytes the following expression is used: "info.freeram * info.mem_unit" and i have
Linux with 2.6.5-7.151 kernel version. !!!TODO!!! here: figure out the kernel version as before
2.3.23 version the structure indeed returns all the values in bytes and there is no mem_unit
struct member.
5) Changed thresholds to 95% & 64M of memory respectively - I've checked them both on
WinXP & Linux - works fine and smoothly with 1G of RAM. Of couse this is discussible values.
6) Don't think we need to add regression test for this as in the recently contributed reliability
suite some tests fails due to this issue and as this suite will be added to CC, we could track
regression in the future. But just in case, here is the standalone test i used to verify the
fix:
import java.nio.*;

public class Test {
    public static void main(String[] args) {
        final int CAPACITY = 0x2000000; //20M

        for (int i = 0; i < 100; i++) {
            ByteBuffer.allocateDirect(CAPACITY);
            System.out.println("Iteration: " + i);
        }
    }
}

Before the patch:
WinXP: OOM after 41 iterations
Linux: OOM after 80 iterations

After the patch: works ok on both platforms.


Could you please review the patch? Thanks!

> [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: H-3148_2.patch, 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.


Mime
View raw message