MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mem0pool.cc File Reference
#include "mem0pool.h"
#include "srv0srv.h"
#include "sync0sync.h"
#include "ut0mem.h"
#include "ut0lst.h"
#include "ut0byte.h"
#include "mem0mem.h"
#include "srv0start.h"
Include dependency graph for mem0pool.cc:

Go to the source code of this file.

Classes

struct  mem_pool_t

Macros

#define MEM_AREA_FREE   1
#define MEM_AREA_MIN_SIZE   (2 * MEM_AREA_EXTRA_SIZE)

Functions

UNIV_INLINE void mem_pool_mutex_enter (mem_pool_t *pool)
UNIV_INLINE void mem_pool_mutex_exit (mem_pool_t *pool)
UNIV_INLINE ulint mem_area_get_size (mem_area_t *area)
UNIV_INLINE void mem_area_set_size (mem_area_t *area, ulint size)
UNIV_INLINE ibool mem_area_get_free (mem_area_t *area)
UNIV_INLINE void mem_area_set_free (mem_area_t *area, ibool free)
UNIV_INTERN mem_pool_tmem_pool_create (ulint size)
UNIV_INTERN void mem_pool_free (mem_pool_t *pool)
UNIV_INTERN void * mem_area_alloc (ulint *psize, mem_pool_t *pool)
UNIV_INLINE mem_area_tmem_area_get_buddy (mem_area_t *area, ulint size, mem_pool_t *pool)
UNIV_INTERN void mem_area_free (void *ptr, mem_pool_t *pool)
UNIV_INTERN ibool mem_pool_validate (mem_pool_t *pool)
UNIV_INTERN void mem_pool_print_info (FILE *outfile, mem_pool_t *pool)
UNIV_INTERN ulint mem_pool_get_reserved (mem_pool_t *pool)

Variables

UNIV_INTERN mem_pool_tmem_comm_pool = NULL
UNIV_INTERN ulint mem_n_threads_inside = 0

Detailed Description

The lowest-level memory management

Created 5/12/1997 Heikki Tuuri

Definition in file mem0pool.cc.

Macro Definition Documentation

#define MEM_AREA_FREE   1

Mask used to extract the free bit from area->size

Definition at line 95 of file mem0pool.cc.

#define MEM_AREA_MIN_SIZE   (2 * MEM_AREA_EXTRA_SIZE)

The smallest memory area total size

Definition at line 98 of file mem0pool.cc.

Function Documentation

UNIV_INTERN void* mem_area_alloc ( ulint *  psize,
mem_pool_t pool 
)

Allocates memory from a pool. NOTE: This low-level function should only be used in mem0mem.*!

Returns
own: allocated memory buffer
Parameters
psizein: requested size in bytes; for optimum space usage, the size should be a power of 2 minus MEM_AREA_EXTRA_SIZE; out: allocated size in bytes (greater than or equal to the requested size)
poolin: memory pool

Definition at line 364 of file mem0pool.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN void mem_area_free ( void *  ptr,
mem_pool_t pool 
)

Frees memory to a pool.

Parameters
ptrin, own: pointer to allocated memory buffer
poolin: memory pool

Definition at line 506 of file mem0pool.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INLINE mem_area_t* mem_area_get_buddy ( mem_area_t area,
ulint  size,
mem_pool_t pool 
)

Gets the buddy of an area, if it exists in pool.

Returns
the buddy, NULL if no buddy in pool
Parameters
areain: memory area
sizein: memory area size
poolin: memory pool

Definition at line 467 of file mem0pool.cc.

Here is the caller graph for this function:

UNIV_INLINE ibool mem_area_get_free ( mem_area_t area)

Returns memory area free bit.

Returns
TRUE if free
Parameters
areain: area

Definition at line 189 of file mem0pool.cc.

Here is the caller graph for this function:

UNIV_INLINE ulint mem_area_get_size ( mem_area_t area)

Returns memory area size.

Returns
size
Parameters
areain: area

Definition at line 164 of file mem0pool.cc.

Here is the caller graph for this function:

UNIV_INLINE void mem_area_set_free ( mem_area_t area,
ibool  free 
)

Sets memory area free bit.

Parameters
areain: area
freein: free bit value

Definition at line 203 of file mem0pool.cc.

Here is the caller graph for this function:

UNIV_INLINE void mem_area_set_size ( mem_area_t area,
ulint  size 
)

Sets memory area size.

Parameters
areain: area
sizein: size

Definition at line 175 of file mem0pool.cc.

Here is the caller graph for this function:

UNIV_INTERN mem_pool_t* mem_pool_create ( ulint  size)

Creates a memory pool.

Returns
memory pool
Parameters
sizein: pool size in bytes

Definition at line 220 of file mem0pool.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN void mem_pool_free ( mem_pool_t pool)

Frees a memory pool.

Parameters
poolin, own: memory pool

Definition at line 279 of file mem0pool.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN ulint mem_pool_get_reserved ( mem_pool_t pool)

Returns the amount of reserved memory.

Returns
reserved memory in bytes
Parameters
poolin: memory pool

Definition at line 714 of file mem0pool.cc.

Here is the caller graph for this function:

UNIV_INLINE void mem_pool_mutex_enter ( mem_pool_t pool)

Reserves the mem pool mutex if we are not in server shutdown. Use this function only in memory free functions, since only memory free functions are used during server shutdown.

Parameters
poolin: memory pool

Definition at line 135 of file mem0pool.cc.

Here is the caller graph for this function:

UNIV_INLINE void mem_pool_mutex_exit ( mem_pool_t pool)

Releases the mem pool mutex if we are not in server shutdown. As its corresponding mem_pool_mutex_enter() function, use it only in memory free functions

Parameters
poolin: memory pool

Definition at line 150 of file mem0pool.cc.

Here is the caller graph for this function:

UNIV_INTERN void mem_pool_print_info ( FILE *  outfile,
mem_pool_t pool 
)

Prints info of a memory pool.

Parameters
outfilein: output file to write to
poolin: memory pool

Definition at line 680 of file mem0pool.cc.

Here is the call graph for this function:

UNIV_INTERN ibool mem_pool_validate ( mem_pool_t pool)

Validates a memory pool.

Returns
TRUE if ok
Parameters
poolin: memory pool

Definition at line 636 of file mem0pool.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

UNIV_INTERN mem_pool_t* mem_comm_pool = NULL

The common memory pool

Definition at line 116 of file mem0pool.cc.