public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "nsz at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug malloc/14581] memalign allocations are often not reused after free
Date: Thu, 08 Dec 2022 14:10:37 +0000	[thread overview]
Message-ID: <bug-14581-131-BmRamM5xC3@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-14581-131@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=14581

Szabolcs Nagy <nsz at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nsz at gcc dot gnu.org

--- Comment #20 from Szabolcs Nagy <nsz at gcc dot gnu.org> ---
i think i ran into this or a similar issue, but the proposed patch "[v4,1/1]
memalign: Support scanning for aligned chunks." does not seem to help.

example: 100 iterations where each iteration leaks 16+64 bytes, everything else
is freed, but every iteration seems to increase the heap by 3231744 bytes at
least. with GLIBC_TUNABLES=glibc.malloc.mmap_threshold=600000 there is no issue
(large allocations turn into mmap/munmap pairs).

#include <stdlib.h>
#include <string.h>
static void *volatile q;
static void use(void *p){ q = p; }
int main(int argc, char *argv[])
{
        void *p1;
        void *p2;
        void *p3;
        for (int i=0; i < 100; i++) {
                p1 = aligned_alloc(512, 1176064);
                memset(p1, 0, 1176064);
                p2 = malloc(16);
                p3 = malloc(64);
                use(p1);
                use(p2);
                use(p3);
                free(p1);
                p1 = aligned_alloc(256, 646656);
                p2 = aligned_alloc(1024, 3232768);
                memset(p2, 0, 3232768);
                p3 = malloc(128);
                use(p1);
                use(p2);
                use(p3);
                free(p2);
                free(p3);
                free(p1);
        }
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2022-12-08 14:10 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-14  9:41 [Bug malloc/14581] New: glibc leaks memory and do not reuse after free (leading to unlimited RSS growth) dev at parallels dot com
2012-09-14 19:27 ` [Bug malloc/14581] " bugdal at aerifal dot cx
2012-09-15 10:40 ` dev at parallels dot com
2012-09-15 10:44 ` dev at parallels dot com
2012-09-15 12:39 ` bugdal at aerifal dot cx
2012-09-15 14:08 ` bugdal at aerifal dot cx
2012-09-15 21:00 ` bugdal at aerifal dot cx
2012-09-16  9:44 ` dev at parallels dot com
2012-09-16 12:46 ` bugdal at aerifal dot cx
2013-05-13  9:30 ` siddhesh at redhat dot com
2013-05-20 15:12 ` ondra at iuuk dot mff.cuni.cz
2013-05-20 15:39 ` siddhesh at redhat dot com
2014-06-17  4:31 ` fweimer at redhat dot com
2020-04-28 20:05 ` [Bug malloc/14581] memalign allocations are often not reused after free mail at nh2 dot me
2021-11-25 18:05 ` carlos at redhat dot com
2022-08-02 22:20 ` mirh at protonmail dot ch
2022-08-10  4:00 ` carlos at redhat dot com
2022-12-08 14:10 ` nsz at gcc dot gnu.org [this message]
2022-12-08 14:47 ` acoplan at gcc dot gnu.org
2022-12-08 16:13 ` carlos at redhat dot com
2022-12-14 21:50 ` dj at redhat dot com
2022-12-15 10:29 ` nsz at gcc dot gnu.org
2022-12-15 10:45 ` nsz at gcc dot gnu.org
2022-12-15 21:44 ` dj at redhat dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-14581-131-BmRamM5xC3@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).