Agent in out of memory looping error - worked around


#1

WORKED AROUND ISSUE BY CREATING NEW ACCOUNT (see below post).

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


#2

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


#3

It won’t run the server.save() call to see what it returns.

Agent code:

local value = 0;
local fifoTable = {};
fifoTable = {“zero”: value};
server.log(server.save(fifoTable));

Device code:

server.log(“device started empty”);

Log:

|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.


#4

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).


#5

We’ve seen a similar problem once before: the server.save() 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.


#6

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:


#7

How do I get the agent reset?
I’ve put the imp005 (referred to in initial post) back to my account after almost 6 months and the first thing it does is report out of memory looping with:

2018-09-17 12:35:48 +09:30 [Agent] ERROR: Out of memory (1024kB used)
2018-09-17 12:35:58 +09:30 [Status] Agent restarted: after delay.

I thought if I move the imp to a different account for a while (more than 5 months) the agent would be cleared and reconstructed when I re-connect.

The code it had in the agent side is:

server.log("**** Agent code starts");
local fifoTable = {};
local value = 0;
fifoTable = {"value": 0};
server.save(fifoTable);

Thanks for your help :slight_smile:


#8

Is that the complete agent code? The listed code alone won’t cause the OOM errors (at least not for me).

Just comment out all of your agent code and restart the device in impCentral. That will restart the agent with no code, allowing you to debug as you add it back.


#9

HiTony,
No luck.
Blank Agent and just a server.log(“device started”) in device side returns:

2018-09-17 22:14:26 +09:30 [Status] Downloading new code; 0.26% program storage used
2018-09-17 22:14:27 +09:30 [Device] device started
2018-09-17 22:14:26 +09:30 [Status] Agent started.
2018-09-17 22:14:26 +09:30 [Agent] ERROR: Out of memory (1024kB used)
2018-09-17 22:14:34 +09:30 [Status] Agent restarted: after delay.

#10

If you give me the device ID, I can clear the saved data for the agent.


#11

Hi Roger,
Details sent in a PM.
Thanks. :smile:


#12

Done. (filler to make this up to the minimum required 20 characters)