public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug malloc/14827] New: free() doesn't honor M_TRIM_THRESHOLD
@ 2012-11-10 23:54 glibc at iamsergio dot de
  2012-11-16 17:03 ` [Bug malloc/14827] " glibc at iamsergio dot de
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: glibc at iamsergio dot de @ 2012-11-10 23:54 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=14827

             Bug #: 14827
           Summary: free() doesn't honor M_TRIM_THRESHOLD
           Product: glibc
           Version: 2.16
            Status: NEW
          Severity: normal
          Priority: P2
         Component: malloc
        AssignedTo: unassigned@sourceware.org
        ReportedBy: glibc@iamsergio.de
    Classification: Unclassified


Created attachment 6725
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6725
test-case

free() isn't calling brk() to give memory back to the kernel when
M_TRIM_THRESHOLD is passed.

Run the attached test-case.

What it does:
1. Calls malloc() 2800000 times
2. Calls free()   2800000 times
3. pauses, so you can inspect the heap size.

You'll see that the heap size is around 250 MB.

Manually calling malloc_trim(), through gdb, decreases the heap size to 4 K.
----------------------------------------------------

How I measured heap size:

  $ cat /proc/12345/maps | grep heap
    01bc6000-0f180000 rw-p 00000000 00:00 0    [heap]

  $ python
    > (0x0f180000-0x01bc6000) / (1024*1024)
    > 213
    213 Megabytes

  $ top -p12345 # tested with top too
    227m 214m for VIRT and RES respectively

  $ gdb -pid 12345            # Lets attach gdb and call malloc_trim()
    > call malloc_trim(0)

  $ top -p12345
    14492 1076 for VIRT and RES respectively

  $ cat /proc/12345/maps | grep heap
    01bc6000-01bc7000 rw-p 00000000 00:00 0 [heap]

  $ python
    > (0x01bc7000-0x01bc6000) / (1024*1024)
    > 0.00390625 // 4KB 
------------------------------------------------------------
I'm on Linux 3.6.5 with glibc-2.16

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug malloc/14827] free() doesn't honor M_TRIM_THRESHOLD
  2012-11-10 23:54 [Bug malloc/14827] New: free() doesn't honor M_TRIM_THRESHOLD glibc at iamsergio dot de
@ 2012-11-16 17:03 ` glibc at iamsergio dot de
  2012-11-18  0:06 ` mail at milianw dot de
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: glibc at iamsergio dot de @ 2012-11-16 17:03 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=14827

--- Comment #1 from Sérgio Martins <glibc at iamsergio dot de> 2012-11-16 17:03:23 UTC ---
This seems to be caused due to the "fastbins" features.

free() doesn't trim fastbins because the malloc() was less than M_MXFAST.

But there really should be a limit to the number of fastbins that we keep
around.

In KDE we've seen 600MB of memory being freed after attaching gdb and calling
malloc_trim(0)

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug malloc/14827] free() doesn't honor M_TRIM_THRESHOLD
  2012-11-10 23:54 [Bug malloc/14827] New: free() doesn't honor M_TRIM_THRESHOLD glibc at iamsergio dot de
  2012-11-16 17:03 ` [Bug malloc/14827] " glibc at iamsergio dot de
@ 2012-11-18  0:06 ` mail at milianw dot de
  2012-11-19 17:04 ` mail at milianw dot de
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mail at milianw dot de @ 2012-11-18  0:06 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=14827

Milian Wolff <mail at milianw dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mail at milianw dot de

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug malloc/14827] free() doesn't honor M_TRIM_THRESHOLD
  2012-11-10 23:54 [Bug malloc/14827] New: free() doesn't honor M_TRIM_THRESHOLD glibc at iamsergio dot de
  2012-11-16 17:03 ` [Bug malloc/14827] " glibc at iamsergio dot de
  2012-11-18  0:06 ` mail at milianw dot de
@ 2012-11-19 17:04 ` mail at milianw dot de
  2013-05-28  8:05 ` bharath.vegito at gmail dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mail at milianw dot de @ 2012-11-19 17:04 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=14827

--- Comment #2 from Milian Wolff <mail at milianw dot de> 2012-11-19 17:04:08 UTC ---
I can reproduce this issue and think its also an issue for KDevelop and similar
apps. What else is needed to improve the situation here?

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug malloc/14827] free() doesn't honor M_TRIM_THRESHOLD
  2012-11-10 23:54 [Bug malloc/14827] New: free() doesn't honor M_TRIM_THRESHOLD glibc at iamsergio dot de
                   ` (2 preceding siblings ...)
  2012-11-19 17:04 ` mail at milianw dot de
@ 2013-05-28  8:05 ` bharath.vegito at gmail dot com
  2014-06-14 11:11 ` fweimer at redhat dot com
  2020-04-28 17:03 ` carlos at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: bharath.vegito at gmail dot com @ 2013-05-28  8:05 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=14827

Bharath H S <bharath.vegito at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bharath.vegito at gmail dot com

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug malloc/14827] free() doesn't honor M_TRIM_THRESHOLD
  2012-11-10 23:54 [Bug malloc/14827] New: free() doesn't honor M_TRIM_THRESHOLD glibc at iamsergio dot de
                   ` (3 preceding siblings ...)
  2013-05-28  8:05 ` bharath.vegito at gmail dot com
@ 2014-06-14 11:11 ` fweimer at redhat dot com
  2020-04-28 17:03 ` carlos at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: fweimer at redhat dot com @ 2014-06-14 11:11 UTC (permalink / raw)
  To: glibc-bugs

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

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|                            |security-

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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug malloc/14827] free() doesn't honor M_TRIM_THRESHOLD
  2012-11-10 23:54 [Bug malloc/14827] New: free() doesn't honor M_TRIM_THRESHOLD glibc at iamsergio dot de
                   ` (4 preceding siblings ...)
  2014-06-14 11:11 ` fweimer at redhat dot com
@ 2020-04-28 17:03 ` carlos at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: carlos at redhat dot com @ 2020-04-28 17:03 UTC (permalink / raw)
  To: glibc-bugs

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

Carlos O'Donell <carlos at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://bugzilla.redhat.com
                   |                            |/show_bug.cgi?id=921676

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-04-28 17:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-10 23:54 [Bug malloc/14827] New: free() doesn't honor M_TRIM_THRESHOLD glibc at iamsergio dot de
2012-11-16 17:03 ` [Bug malloc/14827] " glibc at iamsergio dot de
2012-11-18  0:06 ` mail at milianw dot de
2012-11-19 17:04 ` mail at milianw dot de
2013-05-28  8:05 ` bharath.vegito at gmail dot com
2014-06-14 11:11 ` fweimer at redhat dot com
2020-04-28 17:03 ` carlos at redhat dot com

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