ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 49326] OutOfMemoryError: Map failed
Date Sat, 22 May 2010 21:28:46 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=49326

--- Comment #6 from Bruce Atherton <bruce@callenish.com> 2010-05-22 17:28:44 EDT ---
(In reply to comment #3)
> Currently I wrote down this:
> with MAX_IO_CHUNCK_SIZE = 10MiB
> 
>                 long count = srcChannel.size();
>                 while (position < count) {
>                     long chunck = Math.min(MAX_IO_CHUNCK_SIZE, count -
> position);
>                     position +=
>                         srcChannel.transferTo(position, chunck,
>                                               destChannel);
>                     System.gc();
>                     System.runFinalization();
>                 }

Why not use the recommended workaround from Bug# 6417205, something like:

    // MAX_IO_CHUNK_SIZE = 10MiB
    long count = srcChannel.size();
    while (position < count) {
        long chunk = Math.min(MAX_IO_CHUNK_SIZE, count - position);
        try {
            long readBytes = srcChannel.transferTo(position, 
                    chunk, destChannel);
        } catch (java.io.IOException e) {
            System.gc();
            System.runFinalization();
            long readBytes = srcChannel.transferTo(position, 
                    chunk, destChannel);
        }
        position += readBytes;
    }

That way, the garbage collection only happens when it is needed, and will never
effect a JVM that has this bug fixed.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

Mime
View raw message