One of the most painful troubleshooting tasks with MySQL is
  troubleshooting memory usage. The problem usually starts like
  this – you have configured MySQL to use reasonable global
  buffers, such as
  innodb_buffer_size, key_buffer_size etc, you have reasonable
  amount of connections but yet MySQL takes much more memory than
  you would expect, causing swapping or other problems.
  This simple problem on the surface becomes challenge with MySQL
  because there are no clear resource usage metrics available, and
  so in most cases you do not know where exactly memory is
  allocated. This was not much of the problem in MySQL 3.23 when
  there would only handful of places where memory could be
  allocated but it is a lot larger problems with MySQL 5.5 with
  addition of user variables, stored procedures, prepared
  statements etc which can be a memory hog.
  My intent with this post is dual. I would encourage MySQL Team at
  Oracle, MariaDB team or …
[Read more]