{"id":6620,"date":"2021-07-08T18:20:49","date_gmt":"2021-07-08T12:50:49","guid":{"rendered":"https:\/\/www.skynats.com\/?p=6620"},"modified":"2025-04-01T11:30:11","modified_gmt":"2025-04-01T06:00:11","slug":"error-1038-mysql-memory-allocation-error","status":"publish","type":"post","link":"https:\/\/www.skynats.com\/blog\/error-1038-mysql-memory-allocation-error\/","title":{"rendered":"Error 1038: Mysql memory allocation error"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Some of our clients are getting this MySQL Error 1038 memory allocation issue in their environment. This error occurs when <a href=\"https:\/\/www.mysql.com\/\" target=\"_blank\" rel=\"noopener\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-secondary-color\">MySQL<\/mark><\/a> memory is insufficient to perform a query.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-cause-of-the-mysql-error-1038\" style=\"font-size:18px\"><strong>Cause of the MySQL Error 1038:<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>Error \"1038 Out of memory, consider increasing server sort buffer size<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This situation points to the fact that the MySQL assigned memory is not enough to perform a MySQL query. To perform every session, the sort allocates a buffer of this size.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-method-to-fix-this-issue\" style=\"font-size:18px\"><strong>Method to Fix This Issue:<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In order to fix this error, we have to optimize the query or increase the sort_buffer_size variable value for MySQL.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The sort_buffer_size variable controls how large a filesort buffer is, which means that whenever a query needs to sort the rows, the value given to this variable is used to limit the size that needs to be allocated.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can increase the mysql sort_buffer size in two ways:<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-1-using-a-mysql-query-temporary-method\" style=\"font-size:18px\">1. Using a MySQL<strong> query (temporary method)<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can do it by running the given query <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SET GLOBAL sort_buffer_size = 256000000<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">But it will reset after the restart.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We can increase the sort_buffer_size in the \/etc\/my.cnf  or in \/etc\/mysql\/mysql.conf.d\/ or \/etc\/mysql\/conf.d\/ (depends upon your MySQL configuration file).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;mysqld]\nsort_buffer_size = 256 k<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You need to restart the MySQL server after the changes are done.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>service mysqld restart<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If you are facing any issues with your MySQL server, contact our <a href=\"https:\/\/www.skynats.com\/contact-us\/\" target=\"_blank\" rel=\"noreferrer noopener\"><span style=\"color:#04597e\" class=\"has-inline-color\">sup<\/span><span style=\"color:#066086\" class=\"has-inline-color\">port <\/span><span style=\"color:#075e83\" class=\"has-inline-color\">team<\/span><\/a> right now to get it fixed.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some of our clients are getting this MySQL Error 1038 memory allocation issue in their environment. This error occurs when MySQL memory is insufficient to perform a query. Cause of the MySQL Error 1038: This situation points to the fact that the MySQL assigned memory is not enough to perform a MySQL query. To perform [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,257],"tags":[433,659],"class_list":["post-6620","post","type-post","status-publish","format-standard","hentry","category-blog","category-mysql","tag-error-1038","tag-memory-allocation"],"_links":{"self":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/6620","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/comments?post=6620"}],"version-history":[{"count":4,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/6620\/revisions"}],"predecessor-version":[{"id":14572,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/6620\/revisions\/14572"}],"wp:attachment":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/media?parent=6620"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/categories?post=6620"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/tags?post=6620"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}