summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdlib/malloc.3
Commit message (Collapse)AuthorAgeFilesLines
* Import jemalloc 9ef7f5dc34ff02f50d401e41c8d9a4a928e7c2aa (dev branch,jasone2012-04-171-591/+0
| | | | | | | | prior to 3.0.0 release) as contrib/jemalloc, and integrate it into libc. The code being imported by this commit diverged from lib/libc/stdlib/malloc.c in March 2010, which means that a portion of the jemalloc 1.0.0 ChangeLog entries are relevant, as are the entries for all subsequent releases.
* Correct a typo in the malloc(3) manpage. Malloc options are set in therstone2011-03-071-2/+2
| | | | | | | MALLOC_OPTIONS environment variable, not JEMALLOC_OPTIONS. Reviewed by: jasone Approved by: emaste (mentor)
* mdoc: drop redundant .Pp and .LP callsuqs2010-10-081-1/+0
| | | | They have no effect when coming in pairs, or before .Bl/.Bd
* Revert changes of 'assure' to 'ensure' made in r211936.brucec2010-09-111-2/+2
| | | | Approved by: rrs (mentor)
* Fix incorrect usage of 'assure' and 'insure'.brucec2010-08-281-2/+2
| | | | Approved by: rrs (mentor)
* Fix typos and spelling mistakes.joel2010-08-061-1/+1
|
* Fix bugs:jasone2010-01-311-71/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Fix a race in chunk_dealloc_dss(). * Check for allocation failure before zeroing memory in base_calloc(). Merge enhancements from a divergent version of jemalloc: * Convert thread-specific caching from magazines to an algorithm that is more tunable, and implement incremental GC. * Add support for medium size classes, [4KiB..32KiB], 2KiB apart by default. * Add dirty page tracking for pages within active small/medium object runs. This allows malloc to track precisely which pages are in active use, which makes dirty page purging more effective. * Base maximum dirty page count on proportion of active memory. * Use optional zeroing in arena_chunk_alloc() to avoid needless zeroing of chunks. This is useful in the context of DSS allocation, since a long-lived application may commonly recycle chunks. * Increase the default chunk size from 1MiB to 4MiB. Remove feature: * Remove the dynamic rebalancing code, since thread caching reduces its utility.
* Make malloc(3) superpage aware. Specifically, if getpagesizes(3) returnsalc2009-09-261-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | a large page size that is greater than malloc(3)'s default chunk size but less than or equal to 4 MB, then increase the chunk size to match the large page size. Most often, using a chunk size that is less than the large page size is not a problem. However, consider a long-running application that allocates and frees significant amounts of memory. In particular, it frees enough memory at times that some of that memory is munmap()ed. Up until the first munmap(), a 1MB chunk size is just fine; it's not a problem for the virtual memory system. Two adjacent 1MB chunks that are aligned on a 2MB boundary will be promoted automatically to a superpage even though they were allocated at different times. The trouble begins with the munmap(), releasing a 1MB chunk will trigger the demotion of the containing superpage, leaving behind a half-used 2MB reservation. Now comes the real problem. Unfortunately, when the application needs to allocate more memory, and it recycles the previously munmap()ed address range, the implementation of mmap() won't be able to reuse the reservation. Basically, the coalescing rules in the virtual memory system don't allow this new range to combine with its neighbor. The effect being that superpage promotion will not reoccur for this range of addresses until both 1MB chunks are freed at some point in the future. Reviewed by: jasone MFC after: 3 weeks
* Revert to preferring mmap(2) over sbrk(2) when mapping memory, due tojasone2008-11-031-1/+1
| | | | | | | potential extreme contention in the kernel for multi-threaded applications on SMP systems. Reported by: kris
* Add thread-specific caching for small size classes, based on magazines.jasone2008-08-271-25/+52
| | | | | | | | | | | | | | | | | | | | | | | | This caching allows for completely lock-free allocation/deallocation in the steady state, at the expense of likely increased memory use and fragmentation. Reduce the default number of arenas to 2*ncpus, since thread-specific caching typically reduces arena contention. Modify size class spacing to include ranges of 2^n-spaced, quantum-spaced, cacheline-spaced, and subpage-spaced size classes. The advantages are: fewer size classes, reduced false cacheline sharing, and reduced internal fragmentation for allocations that are slightly over 512, 1024, etc. Increase RUN_MAX_SMALL, in order to limit fragmentation for the subpage-spaced size classes. Add a size-->bin lookup table for small sizes to simplify translating sizes to size classes. Include a hard-coded constant table that is used unless custom size class spacing is specified at run time. Add the ability to disable tiny size classes at compile time via MALLOC_TINY.
* Remove support for lazy deallocation. Benchmarks across a wide range ofjasone2008-02-171-12/+1
| | | | | | | | allocation patterns, number of CPUs, and MALLOC_OPTIONS settings indicate that lazy deallocation has the potential to worsen throughput dramatically. Performance degradation occurs when multiple threads try to clear the lazy free cache simultaneously. Various experiments to avoid this bottleneck failed to completely solve this problem, while adding yet more complexity.
* Track dirty unused pages so that they can be purged if they exceed ajasone2008-02-061-15/+17
| | | | | | | | | | | | | | | | | | | | | | | | | threshold, according to the 'F' MALLOC_OPTIONS flag. This obsoletes the 'H' flag. Try to realloc() large objects in place. This substantially speeds up incremental large reallocations in the common case. Fix a bug in arena_ralloc() that caused relocation of sub-page objects even if the old and new sizes were in the same size class. Maintain trees of runs and simplify the per-chunk page map. This allows logarithmic-time searching for sufficiently large runs in arena_run_alloc(), whereas the previous algorithm required linear time in the worst case. Break various large functions into smaller sub-functions, and inline only the functions that are in the fast path for small object allocation/deallocation. Remove an unnecessary check in base_pages_alloc_mmap(). Avoid integer division in choose_arena() for the NO_TLS case on single-CPU systems.
* Enable both sbrk(2)- and mmap(2)-based memory acquisition methods byjasone2008-01-031-12/+12
| | | | | | | | | default. This has the disadvantage of rendering the datasize resource limit irrelevant, but without this change, legitimate uses of more memory than will fit in the data segment are thwarted by default. Fix chunk_alloc_mmap() to work correctly if initial mapping is not chunk-aligned and mapping extension fails.
* Add the 'D' and 'M' run time options, and use them to control whetherjasone2007-12-271-24/+57
| | | | | | | | | | | | | | | | | | memory is acquired from the system via sbrk(2) and/or mmap(2). By default, use sbrk(2) only, in order to support traditional use of resource limits. Additionally, when both options are enabled, prefer the data segment to anonymous mappings, in order to coexist better with large file mappings in applications on 32-bit platforms. This change has the potential to increase memory fragmentation due to the linear nature of the data segment, but from a performance perspective this is mitigated by the use of madvise(2). [1] Add the ability to interpret integer prefixes in MALLOC_OPTIONS processing. For example, MALLOC_OPTIONS=lllllllll can now be specified as MALLOC_OPTIONS=9l. Reported by: [1] rwatson Design review: [1] alc, peter, rwatson
* Document the B and L MALLOC_OPTIONS.jasone2007-11-271-1/+26
|
* Add information about the implications of using mmap(2) instead of sbrk(2).jasone2007-06-151-1/+19
| | | | Submitted by: bmah, jhb
* Update the IMPLEMENTATION NOTES section to reflect recent mallocjasone2007-03-281-13/+30
| | | | enhancements.
* Markup fixes.ru2006-09-171-51/+51
|
* s/soley/solelyschweikh2006-04-131-1/+1
|
* Add malloc_usable_size() to the RETURN VALUES section.jasone2006-04-041-1/+6
|
* Add malloc_usable_size(3).jasone2006-03-281-2/+25
| | | | Discussed with: arch@
* Modify allocation policy, in order to avoid excessive fragmentation forjasone2006-03-171-50/+52
| | | | | | | | | | | | | | | allocation patterns that involve a relatively even mixture of many different size classes. Reduce the chunk size from 16 MB to 2 MB. Since chunks are now carved up using an address-ordered first best fit policy, VM map fragmentation is much less likely, which makes smaller chunks not as much of a risk. This reduces the virtual memory size of most applications. Remove redzones, since program buffer overruns are no longer as likely to corrupt malloc data structures. Remove the C MALLOC_OPTIONS flag, and add H and S.
* Expand contractions.joel2006-02-011-1/+1
|
* Replace malloc(), calloc(), posix_memalign(), realloc(), and free() withjasone2006-01-131-180/+116
| | | | | | | a scalable concurrent allocator implementation. Reviewed by: current@ Approved by: phk, markm (mentor)
* Fix prototype.ru2005-11-231-1/+3
|
* Sort sections.ru2005-01-201-23/+23
|
* Reword recent addition about memory moving.alfred2004-08-191-5/+4
| | | | | | | | Requested by: keramida Bump .Dd Requested by: ru
* Clarify that realloc and reallocf may move the memory allocation.alfred2004-08-181-3/+7
|
* mdoc(7) police: Deal with self-xrefs.ru2002-12-241-1/+1
|
* Document what really occurs when we obtain an error.trhodes2002-12-201-6/+9
| | | | | PR: 43357 Submitted by: David Schultz <dschultz@uclink.Berkeley.EDU>
* mdoc(7) police: Fixed abuses of the .Ar and .Em macros.ru2002-12-181-1/+1
|
* mdoc(7) police: "The .Fn function".ru2002-12-181-1/+3
|
* Uniformly refer to a file system as "file system".ru2002-12-121-1/+1
| | | | Approved by: re
* Consistently mark std(in|out|err) with .Dv, because that's how theyru2002-12-041-2/+6
| | | | | | | are marked up in stdio(3), and because they are defined expressions of type "FILE *". Approved by: re
* Clarify the bit about realloc() and its `ptr' argument a bit.keramida2002-06-061-2/+3
| | | | | | | | Hopefully, now it is more clear that the memory referenced by the ptr argument of realloc(ptr,size) is freed and only the return value of realloc() points to a valid memory area upon successful completion. Submitted by: Martin Faxer <gmh003532@brfmasthugget.se>
* mdoc(7) police: nit.ru2002-05-291-1/+1
|
* Constify _malloc_options.phk2002-04-241-2/+2
|
* mdoc(7) police: kill HSBs, add missing comma.ru2001-12-121-8/+13
|
* Be more explicit about the fact that realloc() might return akeramida2001-11-241-0/+4
| | | | | | | different pointer than the one passed to it. PR: docs/31925 Submitted by: Andrew <andrew@ugh.net.au>
* malloc and calloc do not free memory.dd2001-11-051-2/+3
| | | | | PR: 31365 Submitted by: SUZUKI Koichi <koich@cac.co.jp>
* Move to using .In instead of .Fd #include <> for include mark-up.asmodai2001-09-071-1/+1
| | | | Inspired by comment from: dd
* Markup nits: use diagnostic type lists for error and warning messages.ru2001-08-101-21/+17
| | | | | | | | Backout previous revision. We should not expand plain text xrefs if they appear in the literal text, e.g. in the error or warning message of the library function. (Submitted by: bde) Moved "out of memory" from warning to errors section.
* mdoc(7) police: expand plain text xrefs.ru2001-08-081-1/+4
|
* Remove whitespace at EOL.dd2001-07-151-8/+8
|
* mdoc(7) police: removed HISTORY info from the .Os call.ru2001-07-101-1/+1
|
* mdoc(7) police: remove extraneous .Pp before and/or after .Sh.dd2001-07-091-1/+0
|
* mdoc(7) police: mark NULL with .Dv.ru2001-07-041-8/+24
|
* mdoc(7) police: the BUGS section should go after HISTORY and AUTHORS.dd2001-06-241-6/+6
|
* The fact that phk wrote this is not a bug!dd2001-06-241-5/+2
|
* Reword a sentence to make it proper English.dd2001-06-241-1/+1
|
OpenPOWER on IntegriCloud