From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DBFA03856968; Thu, 6 Jul 2023 15:40:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DBFA03856968 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688658051; bh=30PjXhH9CHge72ikzlebdQOuLp1sbFrA2ORvDq5PLcU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=pvUgHoS4SgGKA5hAN74vGLKMGbEjWtY7yHcmsYWlc4SR4uzlXn/dKptVuWslGuX0y i7iKFHCh4AjOK3SDjlh2IATyUTLjNp4yNMk9I0ih+xeTtO0oDcldNVFeng971I6gi5 0A8vThg3pJY7phsol75fZlkQgntBH8+3y8nTp82I= From: "cvs-commit at gcc dot gnu.org" To: glibc-bugs@sourceware.org Subject: [Bug malloc/30579] trim_threshold in realloc lead to high memory usage Date: Thu, 06 Jul 2023 15:40:51 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: malloc X-Bugzilla-Version: 2.37 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30579 --- Comment #6 from cvs-commit at gcc dot gnu.org --- The release/2.37/master branch has been updated by Siddhesh Poyarekar : https://sourceware.org/git/gitweb.cgi?p=3Dglibc.git;h=3D0930ff8eb35cb493c94= 5f176c3c9ab320f4d1b86 commit 0930ff8eb35cb493c945f176c3c9ab320f4d1b86 Author: Siddhesh Poyarekar Date: Thu Jul 6 11:09:44 2023 -0400 realloc: Limit chunk reuse to only growing requests [BZ #30579] The trim_threshold is too aggressive a heuristic to decide if chunk reuse is OK for reallocated memory; for repeated small, shrinking allocations it leads to internal fragmentation and for repeated larger allocations that fragmentation may blow up even worse due to the dynamic nature of the threshold. Limit reuse only when it is within the alignment padding, which is 2 * size_t for heap allocations and a page size for mmapped allocations. There's the added wrinkle of THP, but this fix ignores it for now, pessimizing that case in favor of keeping fragmentation low. This resolves BZ #30579. Signed-off-by: Siddhesh Poyarekar Reported-by: Nicolas Dusart Reported-by: Aurelien Jarno Reviewed-by: Aurelien Jarno Tested-by: Aurelien Jarno (cherry picked from commit 2fb12bbd092b0c10f1f2083216e723d2406e21c4) --=20 You are receiving this mail because: You are on the CC list for the bug.=