Mysql – Is it possible to determine thesql pre-allocated memory footprint

MySQL

At startup, mysql will use some memory.

Some of the memory is pre-allocated for "key_buffer" and "innodb_buffer_pool_size" ( and other things ).

Is it possible to determine how much memory is pre-allocated ( for data ) and how much memory has been used ?

Thanks

UPDATE:

Let me take an example to explain what I want to ask.
After I start mysql server, it use some memory as part of "key buffer". Say, I set key_buffer=1G. Maybe at startup, mysql server has pre-allocated 200M as "key buffer". Then when users begin to do queries against this server. The server can only get extra 800M as "key buffer".
200 is a random number I pick. And apparently besides key_buffer, there are other things ( such as innnodb buffer ) What I want to know is the exact size or the way to calculate it.

Hope I've explained myself clearly.

Best Answer

Yes, and you absolutely should! Don't set MySQL to have a potential maximum use more than about 80% of available memory.

MySQL has two types of buffers, global and per-connection. Maximum possible memory use is: global buffers + (connection buffers * max connections).

The mysqltuner.pl script will calculate this for you (http://mysqltuner.com/). Here are the values this script uses for calculating:

Global buffers:

key_buffer_size
max_tmp_table_size
innodb_buffer_pool_size
innodb_additional_mem_pool_size
innodb_log_buffer_size
query_cache_size

Per-connection buffers:

read_buffer_size
read_rnd_buffer_size
sort_buffer_size
thread_stack
join_buffer_size

You can find how much memory is currently used from your Operating System.