Agent Memory Limit

I was running a code, where my sensors send data to agent and agent is batching the data unless num samples are received. For a sample set of 10000, I came across following error message from agent.
UTC+5.5[Agent]ERROR: out of memory
2014-07-15 08:00:51 UTC+5.5[Agent]ERROR: at upload_samples:177

Is it a known issue, If yes, what is the memory utilization limit there.

Check out imp.getmemoryfree(), it works for both agent and device. You have 1MB of RAM available in the agent.

It is also the case that a recent change to the code started catching agents which were only very briefly using too much memory, which previously you could sometimes (though not reliably) get away with.


We are running a board with IMP as host controller and two accelerometer
sensors. Accelerometer sensors are sending sensor data periodically, Say
acceleration in x,y and z directions. this data is periodically sent to the
agent, typically every few every hour its sending say 8192, but
since IMP cannot store that much data because of memory limitations this
sample set is broken into say samples of 100 and sent to agent. Agent does the batching of the data and once completed, it uploads the same to cloud.
In our current setup, one sensor is sending 8192 samples sets each sample
having 3 data each of floating data type. Other sensor is sending 4096 sample
sets each sample having 3 data each of floating data type. So total data size
will be approx. 144KB.
All this data is converted into a JSON string before sending to cloud.
In the process of doing it, agents reports “out of memory” error.
Can you suggest a way of doing it without overflowing the memory or if we should follow some guidelines.

  local sample_json = "["+sensor1_json + "," + sensor2_json + "]";
  upload_samples_to_cloud (sample_json, sample_data);

sensor1_json and sensor2_json are the json data for both accelerometer. next
when I call the function upload_samples to cloud, I see this error
2014-07-18 08:18:22 UTC+5.5 [Agent] ERROR: out of memory
2014-07-18 08:18:22 UTC+5.5 [Agent] ERROR: at upload_samples:176

I’m guessing that it might be when data is passed by value, in which case
agent creates a mirror copy of data provided. Does squirrel functions use call
by value methodology?
Moreover is there a better and optimized way of doing it?

The agent has 1MB of memory.

A couple things:

  1. You can use server.log(imp.getmemoryfree()) in your agent to see how much memory it has free at any given point in time.
  2. We have built in functionality to convert a table / array to json: http.jsonencode(object)