[ https://issues.apache.org/jira/browse/POOL-290?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Phil Steitz updated POOL-290: ----------------------------- Fix Version/s: 2.13 > TestSoftRefOutOfMemory goes into infinite loop > ---------------------------------------------- > > Key: POOL-290 > URL: https://issues.apache.org/jira/browse/POOL-290 > Project: Commons Pool > Issue Type: Bug > Reporter: Serge Angelov > Priority: Major > Fix For: 2.13 > > > 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 (v8.20.10#820010)