public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "shubhankargambhir013 at gmail dot com" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sourceware.org Subject: [Bug malloc/30769] malloc_trim is not working correctly for arenas other than arena 0 Date: Mon, 18 Mar 2024 05:13:15 +0000 [thread overview] Message-ID: <bug-30769-131-hPjyJznIM4@http.sourceware.org/bugzilla/> (raw) In-Reply-To: <bug-30769-131@http.sourceware.org/bugzilla/> https://sourceware.org/bugzilla/show_bug.cgi?id=30769 Shubhankar Gambhir <shubhankargambhir013 at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |shubhankargambhir013@gmail. | |com --- Comment #2 from Shubhankar Gambhir <shubhankargambhir013 at gmail dot com> --- In the original example (mem.cpp) given, the MMAP_THRESHOLD is 128KB (by default) in starting and can increase upto 64MB. In first iteration the blocks are mmaped because they are above threshold, now When you free the first 18MB block the MMAP_THRESHOLD is adjusted, so now from 2nd iteration the blocks will be allocated in arenas, and when they are freed they will be added to malloc cache and not given back to os. When you set M_TOP_PAD (or M_TRIM_THRESHOLD, M_MMAP_THRESHOLD, M_MMAP_MAX) MMAP_THRESHOLD is disabled, so the blocks from 2nd iterations also get mmaped and memory is given back to os when they are freed. Further malloc_trim calls madvise(DONT_NEED) on free pages in arenas, this causes pages to be on demand loaded on next access, and the way your program calculates rss is through proc/self/stat. I can see following description in man documentation. ``` number of pages the process has in real memory. This is just the pages which count toward text, data, or stack space. This does not include pages which have not been demand-loaded in, or which are swapped out. This value is inaccurate; ``` -- You are receiving this mail because: You are on the CC list for the bug.
prev parent reply other threads:[~2024-03-18 5:13 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-08-16 11:55 [Bug malloc/30769] New: " sascha.zorn at sap dot com 2023-09-21 14:36 ` [Bug malloc/30769] " sascha.zorn at sap dot com 2024-01-11 9:41 ` fweimer at redhat dot com 2024-03-18 5:13 ` shubhankargambhir013 at gmail dot com [this message]
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-30769-131-hPjyJznIM4@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: linkBe 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).