This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug malloc/14827] New: free() doesn't honor M_TRIM_THRESHOLD


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]