This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Running out of memory?

I'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 is a RamStorageManager.

Here's a code excerpt:

class RamStorageManager : public StorageManager
{
protected:
  static const uint32_t UserEntries = 2;
  static const uint32_t EventEntries = 2;
// Begin
  Otp OTP;
  Information Information;

  Event events[EventEntries];
  User users[UserEntries];
// End

//...
}

Now, if I comment the code between "begin" and "end", everything works fine. Note, the object is a global variable, statically allocated:

RamStorageManager storageManager;

It is actually currently unused (a reference to is is passed to another object, which stores it and doesn't use it). The object doesn't have code anymore (all methods are just "return false", but they are anyway never called).

As far as I know, my object should be stored in global memory, at an offset statically allocated at compile time. It should not affect the heap.

So my wonder is: why do I get a hardfault when my object gets bigger?!

Parents
  • I've tripled check, static in a class means "one global instance, regardless of how many objects you allocate". "ld" is the GNU linker, as far as I know I'm using armlink. Technically I haven't allocated 0 heap, I've got some heap, I'm trying to get a lot more, but my goal isn't either to use heap. I'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.

Reply
  • I've tripled check, static in a class means "one global instance, regardless of how many objects you allocate". "ld" is the GNU linker, as far as I know I'm using armlink. Technically I haven't allocated 0 heap, I've got some heap, I'm trying to get a lot more, but my goal isn't either to use heap. I'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.

Children
No Data
Related