{"id":4360,"date":"2014-03-30T10:03:05","date_gmt":"2014-03-30T10:03:05","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/monodevelop-debugger-crashing-with-no-error-message-using-dijkstras-algorithm-and-2d-array-collection-of-common-programming-errors\/"},"modified":"2014-03-30T10:03:05","modified_gmt":"2014-03-30T10:03:05","slug":"monodevelop-debugger-crashing-with-no-error-message-using-dijkstras-algorithm-and-2d-array-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/monodevelop-debugger-crashing-with-no-error-message-using-dijkstras-algorithm-and-2d-array-collection-of-common-programming-errors\/","title":{"rendered":"MonoDevelop Debugger Crashing with no error message, using Dijkstra&#39;s algorithm and 2D array-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m making an iOS game in Monotouch with C# and MonoDevelop. I&#8217;m having a very strange crash.<\/p>\n<p><strong>Background Information<\/strong>: Making a 2D war game. I&#8217;ve implemented <strong>Dijkstra&#8217;s algorithm<\/strong> to calculate the shortest path from source to destination with objects in-between (example: go from here to there but go around the cars\/trees\/buildings\/or anything in the way automatically). My crash seems to be related to the 2D array of bytes that I created for this implementation of Dijkstra&#8217;s algorithm. See this image if you&#8217;ve never heard of Dijkstra&#8217;s algorithm http:\/\/en.wikipedia.org\/wiki\/File:Dijkstras_progress_animation.gif<\/p>\n<p>Basically, the more nodes I have in my <strong>2D array<\/strong>, the more detail in the soldier&#8217;s movement on the battlefield. If I use 2,400 nodes in my 2D array, everything works\/loads fine. However, if I increase the number of nodes to 4,266 for more detailed coordinates, the program crashes when it&#8217;s calculating the node&#8217;s distances. It get&#8217;s approximately 30% finished before it crashes.<\/p>\n<p><strong>More Details on the crash:<\/strong> <strong>it only crashes when<\/strong> I use Debug\/iPhone mode or Release\/iPhone mode. When I use the Debug\/iPhone Simulator it works fine. And another note, when I build the app and transfer it to my phone using Debug\/iPhone mode, then stop the debugger, open XCode Instruments, it works fine! I can&#8217;t figure out why it would work in the simulator and with XCode Instruments but NOT with the Monodevelop Debug\/iPhone mode. Is XCode Instruments doing something that &#8220;patches&#8221; up the problem? Or is MonoDevelop&#8217;s debugger doing something to &#8220;break&#8221; the program?<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/ZBxrG.png\" \/><\/p>\n<p>Let me explain what you&#8217;re looking at in the screenshot. My app is called &#8220;WarGame&#8221;. Looking at the timeline, the CPU usage was ~100% from around 2 seconds to about 35 seconds. When the CPU usage drops down to zero, it&#8217;s finished loading. So it literally took about 33 seconds to load the 2D Array of Nodes and populate them with Distances.<\/p>\n<p>Keep in mind in this instance that crashes there are 4,266 nodes which means that the 2D array is a byte [4266, 4266] array. So that&#8217;s 18,198,756 bytes in a 2D array. And it loads successfully when being run by XCode Instruments and it loads successfully when run in MonoDevelop&#8217;s Debug\/iPhone Simulator. But it crashes with no error message when run in the Debug\/iPhone mode on my iPhone 4s. The memory usage of this app is approximately 60.73MB seen in the screenshots.<\/p>\n<p>In the instance that does NOT crash, there were 2,400 nodes which means that the 2D array is a byte [2400, 2400] array. So that&#8217;s 5,760,000 bytes in a 2D array. And that one worked fine everywhere.<\/p>\n<p>The problem clearly seems to be, when I increase the number of nodes to around 4,266 or more the program crashes. But I don&#8217;t get an error message, it just stops suddenly when it&#8217;s loading&#8230; <strong>Could this be a garbage collection issue?<\/strong> You&#8217;d think I&#8217;d get an error message for that right? <strong>Could this be an &#8220;out of memory&#8221; issue?<\/strong> But when it loads using XCode&#8217;s Instruments it says I&#8217;m only using 60MB, and I&#8217;ve used up to 150MB in this app as a test before, so I know I can atleast go up to 150MB of memory usage before it crashes with an &#8220;out of memory error&#8221;.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/42Skk.png\" \/> Here&#8217;s a shot of the memory allocations from XCode Instruments<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/umqba.png\" \/> Here&#8217;s a shot of the memory leak&#8217;s page from XCode Instruments<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m making an iOS game in Monotouch with C# and MonoDevelop. I&#8217;m having a very strange crash. Background Information: Making a 2D war game. I&#8217;ve implemented Dijkstra&#8217;s algorithm to calculate the shortest path from source to destination with objects in-between (example: go from here to there but go around the cars\/trees\/buildings\/or anything in the way [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4360","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4360","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4360"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4360\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4360"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4360"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4360"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}