You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Phil Steitz (Jira)" <ji...@apache.org> on 2025/05/24 00:23:00 UTC

[jira] [Resolved] (POOL-290) TestSoftRefOutOfMemory goes into infinite loop

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

Phil Steitz resolved POOL-290.
------------------------------
    Resolution: Fixed

Fixed for 2_X branch in 104c7b84059c6c6b8d171158c8906e0b8167fc1b

> 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.12.2
>
>
> 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)