commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergii Angelov (JIRA)" <j...@apache.org>
Subject [jira] [Created] (POOL-290) TestSoftRefOutOfMemory goes into infinite loop
Date Mon, 23 Feb 2015 02:02:11 GMT
Sergii Angelov created POOL-290:
-----------------------------------

             Summary: TestSoftRefOutOfMemory goes into infinite loop
                 Key: POOL-290
                 URL: https://issues.apache.org/jira/browse/POOL-290
             Project: Commons Pool
          Issue Type: Bug
            Reporter: Sergii Angelov


When running TestSoftOutOfMemory tests, application goes into infinite loop in case if OutOfMemoryError
happens. It happens for each function that tests OutOfMemory case.
For example in this code
{code}
while (pool.getNumIdle() > 0) {
            try {
                long freeMemory = runtime.freeMemory();
                if (freeMemory > Integer.MAX_VALUE) {
                    freeMemory = Integer.MAX_VALUE;
                }
                garbage.add(new byte[Math.min(1024 * 1024, (int)freeMemory/2)]);
            } catch (OutOfMemoryError oome) {
                System.gc();
            }
            System.gc();
        }
{code}

Correct me if I'm wrong, but wouldn't it be more efficient to destroy pool immediatelly if
error happens and wait till we free that piece of memory (for example wait till free memory
increased by the size of current pool).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message