Groups | Search | Server Info | Keyboard shortcuts | Login | Register
Groups > comp.os.linux.development.system > #361
| From | Kaz Kylheku <kaz@kylheku.com> |
|---|---|
| Newsgroups | comp.os.linux.development.system, comp.unix.programmer |
| Subject | Re: [Linux] malloc: small size - small pointer? |
| Followup-To | comp.os.linux.development.system |
| Date | 2011-12-24 06:56 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <jd3t28$77s$1@dont-email.me> (permalink) |
| References | <c36c7bc2-537d-4f24-976f-c08d61e06bb6@w12g2000yqa.googlegroups.com> |
Cross-posted to 2 groups.
Followups directed to: comp.os.linux.development.system
["Followup-To:" header set to comp.os.linux.development.system.] On 2011-09-13, Alex Vinokur <alex.vinokur@gmail.com> wrote: > > > Hi, > > > > Linux 2.6.18-238.1.1.el5 #1 SMP Tue Jan 4 13:32:19 EST 2011 x86_64 > x86_64 x86_64 GNU/Linux > > Intel(R) C++ Intel(R) 64 Compiler XE for applications running on > Intel(R) 64, Version 12.0.4.191 Build 20110427 > > > malloc() returns "small" pointers for small sizes. > Any suugestions for such behavior of the malloc function. > > Are "small" pointers on heap? The glibc malloc uses sbrk() for "small" allocations, and mmap for large ones. There are additional complications. Under multiple threads, there are mmaped arenas, which are used even for "small" allocations. Furthermore, sbrk() can fail because it runs into a mmapped area. In that case, allocation continues with a malloced arena. (I know all this because I debugged a glibc issue a couple of years ago. I was working as the "put together all things Linux, kernel and user" guy, and some developers came to me with the "problem" of malloc not returning all the memory to the OS in a test case.) By the way, the mmap threshold is adjustable. Look up the documentation for the mallopt function.
Back to comp.os.linux.development.system | Previous | Next — Previous in thread | Find similar
[Linux] malloc: small size - small pointer? Alex Vinokur <alex.vinokur@gmail.com> - 2011-09-13 01:17 -0700
Re: [Linux] malloc: small size - small pointer? Xavier Roche <xroche@free.fr.NOSPAM.invalid> - 2011-09-13 10:23 +0200
Re: malloc: small size - small pointer? Alex Vinokur <alex.vinokur@gmail.com> - 2011-09-13 23:21 -0700
Re: malloc: small size - small pointer? Alex Vinokur <alex.vinokur@gmail.com> - 2011-09-13 23:18 -0700
Re: malloc: small size - small pointer? Alex Vinokur <alex.vinokur@gmail.com> - 2011-09-14 00:08 -0700
Re: [Linux] malloc: small size - small pointer? Kaz Kylheku <kaz@kylheku.com> - 2011-12-24 06:56 +0000
csiph-web