From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0611B38582B7; Thu, 6 Jul 2023 15:38:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0611B38582B7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1688657923; bh=H7gYZj1DrbfJBWJJhwLP9mEJbNaAUgNtMNipBIGChqE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=tNY1cF59b2s/48feTBcJgk1gQuq7wiGZTEIrTVFaJp6V9+3VEEvUkiDUtLJzYYF7/ 6u+SH9I5jGf0IQdhGEGsqkm6yTS3ApI6aPnV2HD24olpiCc5Mb7lICBmzcngGAiPY8 SrGEQBQfGNG7IhHb5Wz9phYw5mMtqQj+2ooWr7kw= 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:38:42 +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 #5 from cvs-commit at gcc dot gnu.org --- The master branch has been updated by Siddhesh Poyarekar : https://sourceware.org/git/gitweb.cgi?p=3Dglibc.git;h=3D2fb12bbd092b0c10f1f= 2083216e723d2406e21c4 commit 2fb12bbd092b0c10f1f2083216e723d2406e21c4 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 --=20 You are receiving this mail because: You are on the CC list for the bug.=