#include "univ.i"
#include "ut0mem.h"
#include "ut0byte.h"
#include "ut0rnd.h"
#include "sync0sync.h"
#include "ut0lst.h"
#include "mach0data.h"
#include "mem0dbg.h"
Go to the source code of this file.
Classes | |
struct | mem_block_info_struct |
Defines | |
#define | MEM_HEAP_DYNAMIC 0 /* the most common type */ |
#define | MEM_HEAP_BUFFER 1 |
#define | MEM_HEAP_BTR_SEARCH |
#define | MEM_BLOCK_START_SIZE 64 |
#define | MEM_BLOCK_STANDARD_SIZE (UNIV_PAGE_SIZE >= 16384 ? 8000 : MEM_MAX_ALLOC_IN_BUF) |
#define | MEM_MAX_ALLOC_IN_BUF (UNIV_PAGE_SIZE - 200) |
#define | mem_heap_create(N) |
#define | mem_heap_create_in_buffer(N) |
#define | mem_heap_create_in_btr_search(N) |
#define | mem_heap_free(heap) |
#define | mem_zalloc(N) memset(mem_alloc(N), 0, (N)); |
#define | mem_alloc(N) mem_alloc_func((N), NULL, __FILE__, __LINE__) |
#define | mem_alloc2(N, S) mem_alloc_func((N), (S), __FILE__, __LINE__) |
#define | mem_free(PTR) mem_free_func((PTR), __FILE__, __LINE__) |
#define | MEM_BLOCK_MAGIC_N 764741555 |
#define | MEM_FREED_BLOCK_MAGIC_N 547711122 |
#define | MEM_BLOCK_HEADER_SIZE |
Typedefs | |
typedef struct mem_block_info_struct | mem_block_info_t |
typedef mem_block_info_t | mem_block_t |
typedef mem_block_t | mem_heap_t |
Functions | |
UNIV_INTERN void | mem_init (ulint size) |
UNIV_INTERN void | mem_close (void) |
UNIV_INLINE mem_heap_t * | mem_heap_create_func (ulint n, ulint type, const char *file_name, ulint line) |
UNIV_INLINE void | mem_heap_free_func (mem_heap_t *heap, const char *file_name, ulint line) |
UNIV_INLINE void * | mem_heap_zalloc (mem_heap_t *heap, ulint n) |
UNIV_INLINE void * | mem_heap_alloc (mem_heap_t *heap, ulint n) |
UNIV_INLINE byte * | mem_heap_get_heap_top (mem_heap_t *heap) |
UNIV_INLINE void | mem_heap_free_heap_top (mem_heap_t *heap, byte *old_top) |
UNIV_INLINE void | mem_heap_empty (mem_heap_t *heap) |
UNIV_INLINE void * | mem_heap_get_top (mem_heap_t *heap, ulint n) |
UNIV_INLINE void | mem_heap_free_top (mem_heap_t *heap, ulint n) |
UNIV_INLINE ulint | mem_heap_get_size (mem_heap_t *heap) |
UNIV_INLINE void * | mem_alloc_func (ulint n, ulint *size, const char *file_name, ulint line) |
UNIV_INLINE void | mem_free_func (void *ptr, const char *file_name, ulint line) |
UNIV_INLINE char * | mem_strdup (const char *str) |
UNIV_INLINE char * | mem_strdupl (const char *str, ulint len) |
UNIV_INTERN char * | mem_heap_strdup (mem_heap_t *heap, const char *str) |
UNIV_INLINE char * | mem_heap_strdupl (mem_heap_t *heap, const char *str, ulint len) |
UNIV_INTERN char * | mem_heap_strcat (mem_heap_t *heap, const char *s1, const char *s2) |
UNIV_INTERN void * | mem_heap_dup (mem_heap_t *heap, const void *data, ulint len) |
UNIV_INTERN char * | mem_heap_printf (mem_heap_t *heap, const char *format,...) __attribute__((format(printf |
#define MEM_BLOCK_HEADER_SIZE |
ut_calc_align(sizeof(mem_block_info_t),\ UNIV_MEM_ALIGNMENT)
#define mem_free | ( | PTR | ) | mem_free_func((PTR), __FILE__, __LINE__) |
Use this macro instead of the corresponding function! Macro for memory buffer freeing
Definition at line 243 of file mem0mem.h.
Referenced by btr_estimate_number_of_different_key_vals(), btr_page_split_and_insert(), btr_pcur_copy_stored_position(), btr_pcur_free_for_mysql(), btr_search_drop_page_hash_index(), btr_search_sys_free(), buf_pool_free(), dict_check_tablespaces_and_store_max_id(), dict_close(), dict_create_foreign_constraints(), dict_foreign_parse_drop_constraints(), dict_table_rename_in_cache(), eval_node_free_val_buf(), fil_close(), fil_create_new_single_table_tablespace(), fil_delete_tablespace(), fil_extend_space_to_desired_size(), fil_flush_file_spaces(), fil_load_single_table_tablespaces(), fil_node_create(), fil_open_single_table_tablespace(), fil_rename_tablespace(), fil_reset_too_high_lsns(), fil_space_for_table_exists_in_mem(), hash_table_free(), ib_list_free(), ib_wqueue_free(), ibuf_close(), innobase_shutdown_for_mysql(), lock_sys_close(), os_file_create_subdirs_if_needed(), page_cur_parse_insert_rec(), rec_copy_prefix_to_buf(), recv_recover_page_func(), recv_sys_close(), recv_sys_mem_free(), row_check_index_for_mysql(), row_create_index_for_mysql(), row_drop_database_for_mysql(), row_drop_tables_for_mysql_in_background(), row_prebuilt_free(), sel_col_prefetch_buf_free(), sess_close(), srv_free(), thr_local_close(), thr_local_free(), trx_free(), trx_purge_sys_close(), trx_roll_savepoint_free(), trx_rseg_mem_free(), trx_savepoint_for_mysql(), trx_sig_remove(), trx_sys_close(), and trx_undo_mem_free().
#define MEM_HEAP_BTR_SEARCH |
#define mem_heap_create | ( | N | ) |
mem_heap_create_func(\ (N), MEM_HEAP_DYNAMIC, __FILE__, __LINE__)
Use this macro instead of the corresponding function! Macro for memory heap creation.
Definition at line 91 of file mem0mem.h.
Referenced by btr_compress(), btr_cur_optimistic_update(), btr_cur_parse_update_in_place(), btr_cur_pessimistic_delete(), btr_cur_pessimistic_update(), btr_page_split_and_insert(), btr_pcur_restore_position_func(), btr_root_raise_and_insert(), btr_store_big_rec_extern_fields(), dict_boot(), dict_create_foreign_constraints(), dict_get_first_table_name_in_db(), dict_load_foreigns(), dict_load_sys_table(), dict_load_table(), dict_load_table_on_id(), dict_mem_foreign_create(), dict_mem_index_create(), dict_mem_table_create(), dict_print(), dtuple_convert_big_rec(), ibuf_init_at_db_start(), ind_create_graph_create(), ins_node_create(), lock_move_reorganize_page(), page_validate(), pars_info_create(), pars_sql(), read_cursor_view_create_for_mysql(), ha_innobase::records_in_range(), recv_sys_init(), row_check_index_for_mysql(), row_create_index_for_mysql(), row_create_prebuilt(), row_create_table_for_mysql(), row_drop_table_for_mysql(), row_get_clust_rec(), row_mysql_drop_temp_tables(), row_purge_node_create(), row_rename_table_for_mysql(), row_truncate_table_for_mysql(), row_undo_node_create(), row_vers_build_for_consistent_read(), row_vers_build_for_semi_consistent_read(), row_vers_impl_x_locked_off_kernel(), row_vers_old_has_index_entry(), tab_create_graph_create(), trx_create(), trx_general_rollback_for_mysql(), trx_purge_sys_create(), trx_roll_graph_build(), trx_undo_arr_create(), and upd_node_create().
#define mem_heap_create_in_btr_search | ( | N | ) |
mem_heap_create_func(\ (N), MEM_HEAP_BTR_SEARCH | MEM_HEAP_BUFFER,\ __FILE__, __LINE__)
Use this macro instead of the corresponding function! Macro for memory heap creation.
Definition at line 103 of file mem0mem.h.
Referenced by ha_create_func().
#define mem_heap_create_in_buffer | ( | N | ) |
mem_heap_create_func(\ (N), MEM_HEAP_BUFFER, __FILE__, __LINE__)
Use this macro instead of the corresponding function! Macro for memory heap creation.
Definition at line 97 of file mem0mem.h.
Referenced by recv_sys_init(), and trx_create().
#define mem_heap_free | ( | heap | ) |
mem_heap_free_func(\ (heap), __FILE__, __LINE__)
Use this macro instead of the corresponding function! Macro for memory heap freeing.
Definition at line 111 of file mem0mem.h.
Referenced by btr_compress(), btr_cur_del_mark_set_clust_rec(), btr_cur_open_at_index_side_func(), btr_cur_open_at_rnd_pos_func(), btr_cur_optimistic_delete(), btr_cur_optimistic_update(), btr_cur_parse_del_mark_set_clust_rec(), btr_cur_parse_update_in_place(), btr_cur_pessimistic_delete(), btr_cur_pessimistic_insert(), btr_cur_search_to_nth_level(), btr_cur_update_in_place(), btr_estimate_number_of_different_key_vals(), btr_index_rec_validate(), btr_page_split_and_insert(), btr_pcur_restore_position_func(), btr_root_raise_and_insert(), btr_search_drop_page_hash_index(), btr_search_sys_free(), btr_search_update_hash_on_delete(), btr_search_update_hash_on_insert(), btr_store_big_rec_extern_fields(), dict_boot(), dict_create_foreign_constraints(), dict_foreign_add_to_cache(), dict_get_first_table_name_in_db(), dict_load_foreigns(), dict_load_sys_table(), dict_load_table(), dict_load_table_on_id(), dict_mem_index_free(), dict_mem_table_free(), dict_print(), dtuple_convert_back_big_rec(), dtuple_convert_big_rec(), ha_clear(), ibuf_init_at_db_start(), lock_clust_rec_read_check_and_lock_alt(), lock_move_reorganize_page(), lock_rec_insert_check_and_lock(), lock_rec_print(), lock_sec_rec_modify_check_and_lock(), page_copy_rec_list_end_no_locks(), page_copy_rec_list_end_to_created_page(), page_copy_rec_list_start(), page_cur_insert_rec_low(), page_cur_insert_rec_zip(), page_cur_parse_delete_rec(), page_cur_parse_insert_rec(), page_cur_search_with_match(), page_delete_rec_list_end(), page_delete_rec_list_start(), page_print_list(), page_validate(), pars_info_free(), que_graph_free(), que_graph_free_recursive(), read_cursor_view_close_for_mysql(), rec_convert_dtuple_to_rec(), rec_print(), ha_innobase::records_in_range(), recv_sys_close(), recv_sys_mem_free(), row_build(), row_build_row_ref(), row_build_row_ref_in_tuple(), row_check_index_for_mysql(), row_drop_table_for_mysql(), row_get_clust_rec(), row_ins_check_foreign_constraint(), row_mysql_drop_temp_tables(), row_mysql_prebuilt_free_blob_heap(), row_prebuilt_free(), row_rename_table_for_mysql(), row_search_for_mysql(), row_truncate_table_for_mysql(), row_undo_search_clust_to_pcur(), row_unlock_for_mysql(), row_vers_build_for_consistent_read(), row_vers_build_for_semi_consistent_read(), row_vers_impl_x_locked_off_kernel(), row_vers_old_has_index_entry(), sel_node_free_private(), trx_free(), trx_general_rollback_for_mysql(), trx_purge_sys_close(), trx_undo_arr_free(), and trx_undo_report_row_operation().
#define mem_zalloc | ( | N | ) | memset(mem_alloc(N), 0, (N)); |
Use this macro instead of the corresponding function! Macro for memory buffer allocation
Definition at line 219 of file mem0mem.h.
Referenced by btr_estimate_number_of_different_key_vals(), buf_pool_init(), and fil_init().
UNIV_INLINE void* mem_alloc_func | ( | ulint | n, |
ulint * | size, | ||
const char * | file_name, | ||
ulint | line | ||
) |
NOTE: Use the corresponding macro instead of this function. Allocates a single buffer of memory from the dynamic memory of the C compiler. Is like malloc of C. The buffer must be freed with mem_free.
n | in: requested size in bytes |
size | out: allocated size in bytes, or NULL |
file_name | in: file name where created |
UNIV_INTERN void mem_close | ( | void | ) |
Closes the memory system.
Definition at line 184 of file mem0dbg.cc.
References mem_close(), mem_comm_pool, and mem_pool_free().
Referenced by innobase_shutdown_for_mysql(), and mem_close().
UNIV_INLINE void mem_free_func | ( | void * | ptr, |
const char * | file_name, | ||
ulint | line | ||
) |
NOTE: Use the corresponding macro instead of this function. Frees a single buffer of storage from the dynamic memory of C compiler. Similar to free of C. in: line where created
ptr | in, own: buffer to be freed |
file_name | in: file name where created |
UNIV_INLINE void* mem_heap_alloc | ( | mem_heap_t * | heap, |
ulint | n | ||
) |
Allocates n bytes of memory from a memory heap.
heap | in: memory heap |
Referenced by btr_push_update_extern_fields(), btr_search_info_create(), commit_node_create(), dict_foreign_parse_drop_constraints(), dict_index_add_to_cache(), dict_index_build_node_ptr(), dict_mem_table_create(), dict_process_sys_fields_rec(), dict_process_sys_indexes_rec(), dict_table_rename_in_cache(), dtuple_convert_big_rec(), ha_insert_for_fold_func(), ha_storage_put_memlim(), ib_list_add_after(), ib_list_create_heap(), ib_vector_create(), ib_vector_push(), ind_create_graph_create(), ins_node_create(), mem_heap_dup(), mem_heap_strcat(), opt_search_plan(), pars_assignment_statement(), pars_column_assignment(), pars_elsif_element(), pars_exit_statement(), pars_fetch_statement(), pars_for_statement(), pars_if_statement(), pars_info_add_function(), pars_info_add_id(), pars_info_add_int4_literal(), pars_info_add_literal(), pars_info_add_ull_literal(), pars_info_create(), pars_open_statement(), pars_order_by(), pars_procedure_definition(), pars_return_statement(), pars_row_printf_statement(), pars_while_statement(), que_fork_create(), que_thr_create(), read_cursor_view_create_for_mysql(), rec_get_offsets_func(), roll_node_create(), row_build(), row_build_row_ref(), row_ext_create(), row_purge_node_create(), row_rec_to_index_entry(), row_truncate_table_for_mysql(), row_undo_node_create(), row_upd_replace(), row_vers_build_for_consistent_read(), row_vers_build_for_semi_consistent_read(), sel_node_create(), sym_tab_add_bound_id(), sym_tab_add_bound_lit(), sym_tab_add_id(), sym_tab_add_int_lit(), sym_tab_add_null_lit(), sym_tab_add_str_lit(), sym_tab_create(), tab_create_graph_create(), trx_undo_arr_create(), trx_undo_prev_version_build(), trx_undo_update_rec_get_update(), and upd_node_create().
UNIV_INLINE mem_heap_t* mem_heap_create_func | ( | ulint | n, |
ulint | type, | ||
const char * | file_name, | ||
ulint | line | ||
) |
NOTE: Use the corresponding macros instead of this function. Creates a memory heap. For debugging purposes, takes also the file name and line as arguments.
n | in: desired start block size, this means that a single user buffer of size n will fit in the block, 0 creates a default size block |
type | in: heap type |
file_name | in: file name where created |
Referenced by rec_get_offsets_func().
UNIV_INTERN void* mem_heap_dup | ( | mem_heap_t * | heap, |
const void * | data, | ||
ulint | len | ||
) |
Duplicate a block of data, allocated from a memory heap.
Duplicate a block of data, allocated from a memory heap.
heap | in: memory heap where copy is allocated |
data | in: data to be copied |
len | in: length of data, in bytes |
Definition at line 120 of file mem0mem.cc.
References mem_heap_alloc(), and mem_heap_dup().
Referenced by mem_heap_dup(), mem_heap_strdup(), pars_sql(), rec_copy_prefix_to_dtuple(), row_check_index_for_mysql(), and row_upd_index_parse().
UNIV_INLINE void mem_heap_empty | ( | mem_heap_t * | heap | ) |
Empties a memory heap. The first memory block of the heap is not freed. in: heap to empty
Referenced by btr_page_split_and_insert(), dict_boot(), dict_load_table(), dict_print(), ins_node_set_new_row(), lock_release_off_kernel(), read_view_close_for_mysql(), row_check_index_for_mysql(), row_vers_build_for_consistent_read(), trx_commit_off_kernel(), and trx_purge().
UNIV_INLINE void mem_heap_free_func | ( | mem_heap_t * | heap, |
const char * | file_name, | ||
ulint | line | ||
) |
NOTE: Use the corresponding macro instead of this function. Frees the space occupied by a memory heap. In the debug version erases the heap memory blocks. in: line where freed
heap | in, own: heap to be freed |
file_name | in: file name where freed |
UNIV_INLINE void mem_heap_free_heap_top | ( | mem_heap_t * | heap, |
byte * | old_top | ||
) |
Frees the space in a memory heap exceeding the pointer given. The pointer must have been acquired from mem_heap_get_heap_top. The first memory block of the heap is not freed. in: pointer to old top of heap
heap | in: heap from which to free |
UNIV_INLINE void mem_heap_free_top | ( | mem_heap_t * | heap, |
ulint | n | ||
) |
Frees the topmost element in a memory heap. The size of the element must be given. in: size of the topmost element
heap | in: memory heap |
UNIV_INLINE byte* mem_heap_get_heap_top | ( | mem_heap_t * | heap | ) |
Returns a pointer to the heap top.
UNIV_INLINE ulint mem_heap_get_size | ( | mem_heap_t * | heap | ) |
Returns the space in bytes occupied by a memory heap. in: heap
Referenced by dict_index_add_to_cache(), dict_index_remove_from_cache(), dict_table_add_to_cache(), dict_table_remove_from_cache(), recv_scan_log_recs(), and trx_print().
UNIV_INLINE void* mem_heap_get_top | ( | mem_heap_t * | heap, |
ulint | n | ||
) |
Returns a pointer to the topmost element in a memory heap. The size of the element must be given.
heap | in: memory heap |
UNIV_INTERN char* mem_heap_printf | ( | mem_heap_t * | heap, |
const char * | format, | ||
... | |||
) |
A simple (s)printf replacement that dynamically allocates the space for the formatted string from the given heap. This supports a very limited set of the printf syntax: types 's' and 'u' and length modifier 'l' (which is required for the 'u' type).
heap | in: memory heap |
format | in: format string |
UNIV_INTERN char* mem_heap_strcat | ( | mem_heap_t * | heap, |
const char * | s1, | ||
const char * | s2 | ||
) |
Concatenate two strings and return the result, using a memory heap.
Concatenate two strings and return the result, using a memory heap.
heap | in: memory heap where string is allocated |
s1 | in: string 1 |
s2 | in: string 2 |
Definition at line 134 of file mem0mem.cc.
References mem_heap_alloc(), and mem_heap_strcat().
Referenced by mem_heap_strcat().
UNIV_INTERN char* mem_heap_strdup | ( | mem_heap_t * | heap, |
const char * | str | ||
) |
Duplicates a NUL-terminated string, allocated from a memory heap.
Duplicates a NUL-terminated string, allocated from a memory heap.
heap | in: memory heap where string is allocated |
str | in: string to be copied |
Definition at line 107 of file mem0mem.cc.
References mem_heap_dup(), and mem_heap_strdup().
Referenced by create_table_def(), mem_heap_strdup(), row_drop_table_for_mysql(), and sym_tab_add_bound_id().
UNIV_INLINE char* mem_heap_strdupl | ( | mem_heap_t * | heap, |
const char * | str, | ||
ulint | len | ||
) |
Makes a NUL-terminated copy of a nonterminated string, allocated from a memory heap.
heap | in: memory heap where string is allocated |
str | in: string to be copied |
Referenced by dict_load_column_low(), dict_load_field_low(), dict_load_foreigns(), dict_load_index_low(), dict_load_table_on_id(), dict_process_sys_foreign_col_rec(), dict_process_sys_foreign_rec(), dict_process_sys_tables_rec(), row_mysql_drop_temp_tables(), row_rename_table_for_mysql(), and sym_tab_add_id().
UNIV_INLINE void* mem_heap_zalloc | ( | mem_heap_t * | heap, |
ulint | n | ||
) |
Allocates and zero-fills n bytes of memory from a memory heap.
heap | in: memory heap |
Referenced by dict_mem_foreign_create(), dict_mem_index_create(), dict_mem_table_add_col(), dict_mem_table_create(), page_validate(), and row_create_prebuilt().
UNIV_INTERN void mem_init | ( | ulint | size | ) |
Initializes the memory system. in: common pool size in bytes
Initializes the memory system.
size | in: common pool size in bytes |
Definition at line 147 of file mem0dbg.cc.
References mem_comm_pool, mem_init(), mem_pool_create(), ut_a, and UT_LIST_INIT.
Referenced by mem_init(), and srv_general_init().
UNIV_INLINE char* mem_strdup | ( | const char * | str | ) |
Duplicates a NUL-terminated string.
Referenced by dict_table_rename_in_cache(), fil_delete_tablespace(), fil_node_create(), fil_rename_tablespace(), fil_space_create(), os_file_dirname(), row_create_index_for_mysql(), and trx_savepoint_for_mysql().
UNIV_INLINE char* mem_strdupl | ( | const char * | str, |
ulint | len | ||
) |
Makes a NUL-terminated copy of a nonterminated string.
str | in: string to be copied |
Referenced by dict_check_tablespaces_and_store_max_id(), dict_get_first_table_name_in_db(), and os_file_dirname().