<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Running out of memory?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/20707/running-out-of-memory</link><description>I&amp;#39;m writing a firmware, with SD130, using mbed libraries. 
 Firmware used to run fine. I added a new object, and now, when connecting, it hardfaults.
I put a breakpoint in the connection callback, this breakpoint is never reached. 
 The object I added</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 30 Mar 2017 13:23:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/20707/running-out-of-memory" /><item><title>RE: Running out of memory?</title><link>https://devzone.nordicsemi.com/thread/80808?ContentTypeID=1</link><pubDate>Thu, 30 Mar 2017 13:23:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ce7e18f1-3f11-4c37-b55a-b8da90e4003e</guid><dc:creator>butch</dc:creator><description>&lt;p&gt;I suggest you use debugger to understand the crash.  Assume the &amp;#39;crash&amp;#39; is infinite loop in the default  hardfault handler.  Pause the program and examine the registers to see whether the stack pointer is invalid.  Or some other general purpose register (as a pointer into the heap) is invalid.  Where invalid means: out of range of real memory addresses.  You might need a basic understanding of assembly language and the ARM architecture.  I think there are two sets of registers (for the main context and the interrupt/handler context) and you might need to examine the main context, i.e. where your app was when the hardfault occurred.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Running out of memory?</title><link>https://devzone.nordicsemi.com/thread/80807?ContentTypeID=1</link><pubDate>Mon, 27 Mar 2017 23:58:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3e53bc54-27c0-4c50-a8cc-fea44041f7a3</guid><dc:creator>Jonathan</dc:creator><description>&lt;p&gt;I&amp;#39;ve tripled check, static in a class means &amp;quot;one global instance, regardless of how many objects you allocate&amp;quot;. &amp;quot;ld&amp;quot; is the GNU linker, as far as I know I&amp;#39;m using armlink.
Technically I haven&amp;#39;t allocated 0 heap, I&amp;#39;ve got some heap, I&amp;#39;m trying to get a lot more, but my goal isn&amp;#39;t either to use heap. I&amp;#39;m just trying to solve my crash.
I gave it a lot of thoughts over the weekend and realized it may also be a stack overflow issue.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Running out of memory?</title><link>https://devzone.nordicsemi.com/thread/80806?ContentTypeID=1</link><pubDate>Thu, 23 Mar 2017 16:09:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ccb8c28b-1d73-4b15-95a7-aabc49cfd3db</guid><dc:creator>butch</dc:creator><description>&lt;p&gt;I&amp;#39;m not familiar with Keil.  I use the linker script file .ld to specify zero heap.  What I am asking is: do you intend to have zero use of the heap and specify that somewhere?  I don&amp;#39;t think the compiler knows that you have allocated zero heap (in the linker script), and will generate code to use the heap.  AFAIK, static doesn&amp;#39;t mean you can only have one instance, it means &amp;quot;not on the heap&amp;quot;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Running out of memory?</title><link>https://devzone.nordicsemi.com/thread/80805?ContentTypeID=1</link><pubDate>Thu, 23 Mar 2017 14:52:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:df8365b9-0aa7-4fe7-9f61-32699c6e0e00</guid><dc:creator>Jonathan</dc:creator><description>&lt;p&gt;Oh and sorry, not static because I want to be able to use other instances of the object.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Running out of memory?</title><link>https://devzone.nordicsemi.com/thread/80804?ContentTypeID=1</link><pubDate>Thu, 23 Mar 2017 14:51:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6848243e-a3ef-481e-b747-4bdca0509d1b</guid><dc:creator>Jonathan</dc:creator><description>&lt;p&gt;Heap is allocated thru the scatter file (using Keil) I don&amp;#39;t know of another way to allocate it when not having a arm_startup_nrf51.s . Unless I&amp;#39;m mistaken, &amp;quot;this&amp;quot; will be allocated during compilation. Looking at the map file, the bigger my object is, the bigger my zero-init section is (specifically, the ZI section of my main.o increases with the size of the object).
So I would conclude my object is definitely not on the heap.&lt;/p&gt;
&lt;p&gt;My hypothesis is not valid and was that maybe the SD would allocate something dynamically and run out of memory.
All I know is the issue doesn&amp;#39;t happen if my object is smaller.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Running out of memory?</title><link>https://devzone.nordicsemi.com/thread/80803?ContentTypeID=1</link><pubDate>Thu, 23 Mar 2017 13:26:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9344cb87-33f0-496b-bc31-93254f135733</guid><dc:creator>butch</dc:creator><description>&lt;p&gt;What architectural reason?  I am not sure about it either, but if the properties are not static, they are accessed through a &amp;quot;this&amp;quot; pointer, and I wonder where and when they are allocated.  You did not answer whether you have allocated any heap.  What is your hypothesis about when and why the hard fault occurs?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Running out of memory?</title><link>https://devzone.nordicsemi.com/thread/80802?ContentTypeID=1</link><pubDate>Thu, 23 Mar 2017 10:30:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a9e56cb5-17b1-4ac4-bc10-4299d6352d7e</guid><dc:creator>Jonathan</dc:creator><description>&lt;p&gt;No I don&amp;#39;t want them static (for architecture reasons). Members properties might be on the heap, indeed, though afaik that&amp;#39;s not how it works. I do have some heap allocated in my scatter file, but my own code should not allocate anything on the heap, and as far as I understand neither does the SD.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Running out of memory?</title><link>https://devzone.nordicsemi.com/thread/80801?ContentTypeID=1</link><pubDate>Wed, 22 Mar 2017 15:35:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10e1af1d-de49-407b-8f39-dc6c8d1e7430</guid><dc:creator>butch</dc:creator><description>&lt;p&gt;Maybe you need &amp;quot;static&amp;quot; on the data members of the class e.g &amp;quot;static Otp OTP&amp;quot;.  That is, maybe the data member instances are on the heap.  Also, are you saying that you have no heap allocated in your linker script, so that you will get a hard fault if the compiler generates any code that uses the heap?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>