{"id":36,"date":"2011-05-24T14:30:29","date_gmt":"2011-05-24T19:30:29","guid":{"rendered":"http:\/\/www.matthewcroberts.com\/?page_id=36"},"modified":"2011-05-24T14:30:29","modified_gmt":"2011-05-24T19:30:29","slug":"q11-stack-overflow","status":"publish","type":"page","link":"http:\/\/www.matthewcroberts.com\/?page_id=36","title":{"rendered":"Q11: Stack Overflow"},"content":{"rendered":"<p>Memory is divided into two types: stack and heap. Memory can be allocated and deallocated from the help while a program is running. On Windows, the stack size is fixed, and each time that a variable is declared with fixed dimensions in your Fortran MEX program, it takes some of the stack memory. While this might not be a problem when you pass your MEX file a 1000 element array, when you pass it 1,000,000 elements, it will likely complain.<\/p>\n<p>The trick is to move variable off the stack and onto the heap. The surest way of doing this is by using ALLOCATABLE or POINTER gateways (examples 2 and 3 in\u00a0<a href=\"http:\/\/aede.osu.edu\/people\/roberts.628\/papers\/research\/fmex\/fmexfaqs_p04.html\">FAQ 4<\/a>). Both of these features require an F9x compiler. If you are restricted to F77, then put the large variables in a COMMON block, which should also force them onto the heap.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Memory is divided into two types: stack and heap. Memory can be allocated and deallocated from the help while a program is running. On Windows, the stack size is fixed, and each time that a variable is declared with fixed dimensions in your Fortran MEX program, it takes some of the stack memory. While this [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":24,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-36","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"http:\/\/www.matthewcroberts.com\/index.php?rest_route=\/wp\/v2\/pages\/36","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.matthewcroberts.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.matthewcroberts.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.matthewcroberts.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.matthewcroberts.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=36"}],"version-history":[{"count":0,"href":"http:\/\/www.matthewcroberts.com\/index.php?rest_route=\/wp\/v2\/pages\/36\/revisions"}],"up":[{"embeddable":true,"href":"http:\/\/www.matthewcroberts.com\/index.php?rest_route=\/wp\/v2\/pages\/24"}],"wp:attachment":[{"href":"http:\/\/www.matthewcroberts.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=36"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}