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.
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({})?
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 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.
I don’t exactly know either what caused it. Not to keen to try and replicate 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
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);
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.
Your agent is restarting because it’s running out of memory. Unlike the OP, this isn’t caused by server.save data, so there’s likely a bug in your code. As @hugo says, you can just push new code to your agent by pressing “build and restart”.