Connect memory usage
You are viewing an old version of this article. View
the current version here.
When creating a connection, a THD object is created for that connection. This contains all connection information and also caches to speed up queries and avoid frequent malloc() calls.
When creating a new connection, the following malloc() calls are done for the THD:
Following information is the state in MariaDB 10.6.1 when compiled without debugging.
Local thread memory
This is part of select memory_used from information_schema.processlist
.
Amount allocated | Where allocated | Description |
---|---|---|
26646 | THD::THD | Allocation of THD object |
256 | Statement_map::Statement_map(), my_hash_init(key_memory_prepared_statement_map, &st_hash | Prepared statements |
256 | my_hash_init(key_memory_prepared_statement_map, &names_hash | Names of used prepared statements |
128 | wsrep_wfc(), Opt_trace_context(), dynamic_array() | |
1024 | Diagnostics_area::init(),init_sql_alloc(PSI_INSTRUMENT_ME, &m_warn_root | |
120 | Session_sysvars_tracker, global_system_variables.session_track_system_variables | Tracking of changed session variables |
280 | THD::THD,my_hash_init(key_memory_user_var_entry,&user_vars | |
280 | THD::THD,my_hash_init(PSI_INSTRUMENT_ME, &sequences | Cache of used sequences |
1048 | THD::THD, m_token_array= my_malloc(PSI_INSTRUMENT_ME, max_digest_length | |
16416 | CONNECT::create_thd(), my_net_init(), net_allocate_new_packet() | This is for reading data from the connected user |
16416 | check_connection(), thd->packet.alloc() | This is for sending data to connected user |
Objects stored in THD->memroot during connect
Amount allocated | Where allocated | Description |
---|---|---|
72 | send_server_handshake_packet, mpvio->cached_server_packet.pkt= | |
64 | parse_client_handshake_packet, thd->copy_with_error(...db,db_len) | |
32 | parse_client_handshake_packet, sctx->user= | |
368 | ACL_USER::copy(), root= | |
56 | ACL_USER::copy(), dst->user= safe_lexcstrdup_root(root, user) | |
56 | ACL_USER::copy() | |
56 | ACL_USER::copy() | |
64 | ACL_USER::copy() | |
64 | ACL_USER::copy() | |
32 | mysql_change_db() | |
48 | dbname_cache->insert(db_name) | |
40 | mysql_change_db(), my_register_filename(db.opt) | |
8216 | load_db_opt(), init_io_cache() | Disk cache for reading db.opt |
1112 | load_db_opts(), put_dbopts() |
State at first call to mysql_execute_command
(gdb) p thd->status_var.local_memory_used $24 = 75496 (gdb) p thd->status_var.global_memory_used $25 = 17544 (gdb) p thd->variables.query_prealloc_size $30 = 24576 (gdb) p thd->variables.query_alloc_block_size $29 = 16384
Comments
Comments loading...
Content reproduced on this site is the property of its respective owners,
and this content is not reviewed in advance by MariaDB. The views, information and opinions
expressed by this content do not necessarily represent those of MariaDB or any other party.