Accident to use STL's <deque> on arduino 101.

Hello.
Thanks for taking care of my question the other day.

I use header on my 101.
But, my code is certainly crashed.

Deque stored some data (push_back()).
When stored data exceed 30, front data is deleted (pop_front()).
These deque has 31 or less data.
It is 4 (int size) x 10 (a number of deque) x 31 (a number of data) = 1.240 kbytes.
When 128-th push_back(), my arduino 101 has crashed.

How should I solve it?

I hope you will be able to provide the information.
Daisuke.

The code is below.

#include <deque>
#include <CurieTimerOne.h>

class TimeSeriesData
{
  public:
    std::deque<int> Dummy[10];

  public:
    unsigned int size()
    {
      return Dummy[0].size();
    }

    String outputData()
    {
      if (Dummy[0].size() == 0)
      {
        return outputDummyData();
      }
      else
      {
        return outputFactData();
      }
    }

    String outputFactData()
    {
      String output = "dummy";


      for (auto &a : Dummy)
      {
        a.pop_front();
        a.shrink_to_fit();
      }

      return output;
    }

    String outputDummyData()
    {
      String output = "dummy";

      return output;
    }


    void inputData()
    {
      for (auto &a : Dummy)
      {
        a.push_back(0);
      }
    };

    int getSize()
    {
      int ret = 0;
      for (auto a : Dummy)
      {
        ret += sizeof(int) * a.size();
      }
      return ret;
    }
};


TimeSeriesData Argon;

//SoftwareSerial mySerial(2, 3); // RX, TX

void setup() {
  Serial.begin(115200);
  while (!Serial) ;
  Serial.println("start");
  delay(100);
  CurieTimerOne.start(100000, &timerInt);
}

void loop() {
  if (Argon.size() > 30)
  {
    (Argon.outputData());
  }
}


void timerInt()
{
  int A = micros();
  static int h = 0;
  h++;

  Argon.inputData();

  int B = micros() - A;


  Serial.print("Time:");
  Serial.print(B);
  Serial.print("\t");

  for (auto &a : Argon.Dummy)
  {
    Serial.print(a.size());
    Serial.print("\t");
  }
  Serial.print(Argon.getSize());
  Serial.print("\t");

  Serial.println(h);



}



namespace std {
void __throw_bad_alloc()
{
  Serial.println("Unable to allocate memory");
}

void __throw_length_error(char const*e)
{
  Serial.print("Length Error :");
  Serial.println(e);
}
}

Hello,
Deque is a c++ library, you can't use it in Arduino. Your code also uses some other c++ features (such as the auto keyword). Make sure you are writing code for arduino, not c++.

alane143:
Hello,
Deque is a c++ library, you can't use it in Arduino. Your code also uses some other c++ features (such as the auto keyword). Make sure you are writing code for arduino, not c++.

Hmmm, If Arduino does not support STL, then what is this link all about?

As far as Auto, auto is par of the c++ 11 standard. I do believe it is supported, will have to test this tonight when I get home.