Agent in out of memory looping error - worked around



Somehow got my imp and agent to go crazy and I think I’ve overflowed the agent storage ( I’ve removed the code and just trying to do with an empty table but it’s not working.
Any suggestions how to reset it?
imp005: 5000a408eab9a486


What’s the code returned by the call? What are you seeing in terms of agent logs when you restart the device and then your agent code calls{})?


It won’t run the call to see what it returns.

Agent code:

local value = 0;
local fifoTable = {};
fifoTable = {“zero”: value};

Device code:

server.log(“device started empty”);


|2018-03-23 06:29:14 +10:30|[Status]|Device connected|
|2018-03-23 06:29:14 +10:30|[Status]|Agent started.|
|2018-03-23 06:29:14 +10:30|[Agent]|ERROR: Out of memory (1024kB used)|
|2018-03-23 06:29:14 +10:30|[Device]|device started empty|
|2018-03-23 06:29:18 +10:30|[Status]|Agent restarted: after delay.|
|2018-03-23 06:29:18 +10:30|[Agent]|ERROR: Out of memory (1024kB used)|
|2018-03-23 06:29:28 +10:30|[Status]|Agent restarted: after delay.|
|2018-03-23 06:29:28 +10:30|[Agent]|ERROR: Out of memory (1024kB used)|

The log just continues with the error/agent restarted message pair about every 10secs.


Worked around the issue. Have created a new account and migrated to the new account. If you can find the old agent, you can reset it from looping. Sorry, had to keep working and there was no way for me to reset the agent (I also tried reblinking the device).


We’ve seen a similar problem once before: the data is stored as JSON, and it’s serialised twice. Once inside the agent runtime to check the size, and once inside the Erlang host to actually save the data. The two don’t agree exactly on serialisation, so occasionally a large blob (or string, we’ve not nailed it down) will get transformed into an array of integers.

When that gets read back in, it blows the memory allowance.

The only way to clear this situation is for us to clear the saved data internally, which requires raising a support ticket. Or, as you found, you can change the account associated with the device. Changing it back just puts you back in the same situation, however.

We started work to change the way we store saved data, mainly to remove the restrictions caused by using JSON, but it would also solve this problem. Unfortunately, that work has been temporarily shelved and has dropped down the priority list.


I don’t exactly know either what caused it. Not to keen to try and replicate :slight_smile: I do know things happened very quickly with data coming from the device to the agent. That possibly contributed to it or caused it. Your explanation does make sense though.
For the imp teams consideration - maybe a button or something in the ide that blows away the agent vm and creates a new one. Not sure how that would work or if its even feasible. I’m not a perfect programmer so do at times make mistakes that have the potential to cause a problem too.
Thanks anyway :slight_smile: