Max connection user in mysql
This is an interesting read for How MySQL uses memory
We have,
Global Buffers: key_buffer_size, innodb_buffer_pool_size, innodb_additional_mem_pool_size, innodb_log_buffer_size, query_cache_size
and
Per Thread Buffers: read_buffer_size, read_rnd_buffer_size, sort_buffer_size, join_buffer_size, thread_stack, max_allowed_packet, net_buffer_length
To calculate present status you can download procedure here and just run it from MySQL.
I guess we can formulate number of Threads (nT) = ( R - GB  ) / PTB

Where,
R - Ram
GB - Global Buffers
PTB - Per Thread Buffers