diff options
author | Jason Evans <je@facebook.com> | 2010-09-17 22:46:18 (GMT) |
---|---|---|
committer | Jason Evans <je@facebook.com> | 2010-09-17 22:46:18 (GMT) |
commit | 8e3c3c61b5bb676a705450708e7e79698cdc9e0c (patch) | |
tree | 5cb1ffd5b3cb231a9f69ae40b7bba8351455c2ea /jemalloc/doc | |
parent | 4cc6a60a4f3ee481bdde233d6fa72e256cb9477a (diff) | |
download | jemalloc-8e3c3c61b5bb676a705450708e7e79698cdc9e0c.zip jemalloc-8e3c3c61b5bb676a705450708e7e79698cdc9e0c.tar.gz jemalloc-8e3c3c61b5bb676a705450708e7e79698cdc9e0c.tar.bz2 |
Add {,r,s,d}allocm().
Add allocm(), rallocm(), sallocm(), and dallocm(), which are a
functional superset of malloc(), calloc(), posix_memalign(),
malloc_usable_size(), and free().
Diffstat (limited to 'jemalloc/doc')
-rw-r--r-- | jemalloc/doc/jemalloc.3.in | 169 |
1 files changed, 161 insertions, 8 deletions
diff --git a/jemalloc/doc/jemalloc.3.in b/jemalloc/doc/jemalloc.3.in index 138234a..9dc4b25 100644 --- a/jemalloc/doc/jemalloc.3.in +++ b/jemalloc/doc/jemalloc.3.in @@ -38,7 +38,7 @@ .\" @(#)malloc.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD: head/lib/libc/stdlib/malloc.3 182225 2008-08-27 02:00:53Z jasone $ .\" -.Dd September 11, 2010 +.Dd September 17, 2010 .Dt JEMALLOC 3 .Os .Sh NAME @@ -51,13 +51,18 @@ .Nm @jemalloc_prefix@malloc_stats_print , .Nm @jemalloc_prefix@mallctl , .Nm @jemalloc_prefix@mallctlnametomib , -.Nm @jemalloc_prefix@mallctlbymib +.Nm @jemalloc_prefix@mallctlbymib , +.Nm @jemalloc_prefix@allocm , +.Nm @jemalloc_prefix@rallocm , +.Nm @jemalloc_prefix@sallocm , +.Nm @jemalloc_prefix@dallocm .Nd general purpose memory allocation functions .Sh LIBRARY .Sy libjemalloc@install_suffix@ .Sh SYNOPSIS .In stdlib.h .In jemalloc/jemalloc@install_suffix@.h +.Ss Standard API .Ft void * .Fn @jemalloc_prefix@malloc "size_t size" .Ft void * @@ -68,6 +73,7 @@ .Fn @jemalloc_prefix@realloc "void *ptr" "size_t size" .Ft void .Fn @jemalloc_prefix@free "void *ptr" +.Ss Non-standard API .Ft size_t .Fn @jemalloc_prefix@malloc_usable_size "const void *ptr" .Ft void @@ -82,7 +88,17 @@ .Va @jemalloc_prefix@malloc_options ; .Ft void .Fn \*(lp*@jemalloc_prefix@malloc_message\*(rp "void *cbopaque" "const char *s" +.Ss Experimental API +.Ft int +.Fn @jemalloc_prefix@allocm "void **ptr" "size_t *rsize" "size_t size" "int flags" +.Ft int +.Fn @jemalloc_prefix@rallocm "void **ptr" "size_t *rsize" "size_t size" "size_t extra" "int flags" +.Ft int +.Fn @jemalloc_prefix@sallocm "const void *ptr" "size_t *rsize" "int flags" +.Ft int +.Fn @jemalloc_prefix@dallocm "void *ptr" "int flags" .Sh DESCRIPTION +.Ss Standard API The .Fn @jemalloc_prefix@malloc function allocates @@ -158,7 +174,7 @@ If is .Dv NULL , no action occurs. -.Pp +.Ss Non-standard API The .Fn @jemalloc_prefix@malloc_usable_size function returns the usable size of the allocation pointed to by @@ -289,6 +305,102 @@ for (i = 0; i < nbins; i++) { /* Do something with bin_size... */ } .Ed +.Ss Experimental API +The experimental API is subject to change or removal without regard for +backward compatibility. +.Pp +The +.Fn @jemalloc_prefix@allocm , +.Fn @jemalloc_prefix@rallocm , +.Fn @jemalloc_prefix@sallocm , +and +.Fn @jemalloc_prefix@dallocm +functions all have a +.Fa flags +argument that can be used to specify options. +The functions only check the options that are contextually relevant. +Use bitwise or (|) operations to specify one or more of the following: +.Bl -tag -width ".Dv ALLOCM_LG_ALIGN(la)" +.It ALLOCM_LG_ALIGN(la) +Align the memory allocation to start at an address that is a multiple of +(1 << +.Fa la ) . +This macro does not validate that +.Fa la +is within the valid range. +.It ALLOCM_ALIGN(a) +Align the memory allocation to start at an address that is a multiple of +.Fa a , +where +.Fa a +is a power of two. +This macro does not validate that +.Fa a +is a power of 2. +.It ALLOCM_ZERO +Initialize newly allocated memory to contain zero bytes. +In the growing reallocation case, the real size prior to reallocation defines +the boundary between untouched bytes and those that are initialized to contain +zero bytes. +If this option is absent, newly allocated memory is uninitialized. +.It ALLOCM_NO_MOVE +For reallocation, fail rather than moving the object. +This constraint can apply to both growth and shrinkage. +.El +.Pp +The +.Fn @jemalloc_prefix@allocm +function allocates at least +.Fa size +bytes of memory, sets +.Fa *ptr +to the base address of the allocation, and sets +.Fa *rsize +to the real size of the allocation if +.Fa rsize +is not +.Dv NULL . +.Pp +The +.Fn @jemalloc_prefix@rallocm +function resizes the allocation at +.Fa *ptr +to be at least +.Fa size +bytes, sets +.Fa *ptr +to the base address of the allocation if it moved, and sets +.Fa *rsize +to the real size of the allocation if +.Fa rsize +is not +.Dv NULL . +If +.Fa extra +is non-zero, an attempt is made to resize the allocation to be at least +.Fa ( size ++ +.Fa extra ) +bytes, though an inability to allocate the extra byte(s) will not by itself +result in failure. +Behavior is undefined if +.Fa ( size ++ +.Fa extra +> +.Dv SIZE_T_MAX ) . +.Pp +The +.Fn @jemalloc_prefix@sallocm +function sets +.Fa *rsize +to the real size of the allocation. +.Pp +The +.Fn @jemalloc_prefix@dallocm +function causes the memory referenced by +.Fa ptr +to be made available for future allocations. .Sh TUNING Once, when the first call is made to one of these memory allocation routines, various flags will be set or reset, which affects the @@ -646,11 +758,10 @@ LsR ^^R ^^R LsR -^^R -^^R ^^R. Category;Subcategory;Size -Small;Tiny;8 +@roff_tiny@Small;Tiny;8 +@roff_no_tiny@Small;Tiny;[disabled] ;Quantum-spaced;16 ;;32 ;;48 @@ -681,7 +792,7 @@ Allocations are packed tightly together, which can be an issue for multi-threaded applications. If you need to assure that allocations do not suffer from cacheline sharing, round your allocation requests up to the nearest multiple of the cacheline -size. +size, or specify cacheline alignment when allocating. .Sh MALLCTL NAMESPACE The following names are defined in the namespace accessible via the .Fn @jemalloc_prefix@mallctl* @@ -1412,6 +1523,7 @@ is likely to result in a crash or deadlock. All messages are prefixed by .Dq <jemalloc>: . .Sh RETURN VALUES +.Ss Standard API The .Fn @jemalloc_prefix@malloc and @@ -1460,7 +1572,7 @@ when an error occurs. The .Fn @jemalloc_prefix@free function returns no value. -.Pp +.Ss Non-standard API The .Fn @jemalloc_prefix@malloc_usable_size function returns the usable size of the allocation pointed to by @@ -1502,6 +1614,47 @@ An interface with side effects failed in some way not directly related to .Fn @jemalloc_prefix@mallctl* read/write processing. .El +.Ss Experimental API +The +.Fn @jemalloc_prefix@allocm , +.Fn @jemalloc_prefix@rallocm , +.Fn @jemalloc_prefix@sallocm , +and +.Fn @jemalloc_prefix@dallocm +functions return +.Dv ALLOCM_SUCCESS +on success; otherwise they return an error value. +The +.Fn @jemalloc_prefix@allocm +and +.Fn @jemalloc_prefix@rallocm +functions will fail if: +.Bl -tag -width ".Dv ALLOCM_ERR_OOM" +.It ALLOCM_ERR_OOM +Out of memory. +Insufficient contiguous memory was available to service the allocation request. +The +.Fn @jemalloc_prefix@allocm +function additionally sets +.Fa *ptr +to +.Dv NULL , +whereas the +.Fn @jemalloc_prefix@rallocm +function leaves +.Fa *ptr +unmodified. +.El +.Pp +The +.Fn @jemalloc_prefix@rallocm +function will also fail if: +.Bl -tag -width ".Dv ALLOCM_ERR_NOT_MOVED" +.It ALLOCM_ERR_NOT_MOVED +.Dv ALLOCM_NO_MOVE +was specified, but the reallocation request could not be serviced without +moving the object. +.El .Sh ENVIRONMENT The following environment variables affect the execution of the allocation functions: |