clearTimeout and WARNING: Out of memory while appending to array #3950
Replies: 1 comment
-
Posted at 2014-07-13 by @gfwilliams Will check properly on but it seems that one problem might be that you're not really ever getting rid of the gps module, so for every fix you'll try and stop the interval again. Could it be that a9 isn't actually stopping the gps? I'd maybe add a hasHadFix variable and explicitly ignore any fixes other than the first. Posted at 2014-07-13 by @gfwilliams Also in searchduration you're clearing a timeout which won't exist (because it will have just timed out... That is probably what is giving you your timeout errors... Posted at 2014-07-13 by Hardware_Hacks Thanks for the pointers Gordon I'll take a look. A9 is just an enable pin which disables/enables the GPS running when you change the output. It's worked fine on other devices this way so I would assume your first point and second post are more to do with it. Posted at 2014-07-13 by Hardware_Hacks I just have to let the timeout run its duration it seems. If I try to clear the timeout when I get a fix it seems to produce an error every other (e.g. all even times/2times) time it searches.
Posted at 2014-07-14 by @gfwilliams Could it be that Also, I'd try and call Just a quick JS thing too - if you say Maybe try:
Posted at 2014-07-14 by Hardware_Hacks @gfwilliams ran the code for a couple of hours and I hit:
Is there any way I can trace where the memory is leaking from? Posted at 2014-07-15 by @gfwilliams Hmm... You could try writing It's a really odd one because it looks like The only thing I can think of is that the GPS module doesn't limit the amount of characters it stores in a line, so if you got a few thousand characters without a line break, that could cause a problem. Posted at 2014-07-15 by Hardware_Hacks So I assume best way is to check the differences between two traces() at any time? If so this is what I found: "line" mentioned at line 85/86 is in the underlying GPS module @gfwilliams created for Espruino I think? http://www.espruino.com/modules/GPS.js Edit: Posted at 2014-07-16 by @gfwilliams That's a really handy website :) Yes, diffing is the way to go. So yes, it looks like it's an issue with that module. What is the contents of 'gps.line' when it gets so big? Espruino is relying on a newline being sent by the module, but it might not be sending one for some reason? I'll add some sanity check in there, but I'd hoped that I wouldn't have to... Posted at 2014-07-16 by @gfwilliams Right - I've just updated the GPS module to (hopefully) limit the size of I'd still be interested to see what was in Posted at 2014-07-16 by @gfwilliams Just been running the simple GPS example here, and this happened to me. It seems there's actually a proper memory leak somewhere (almost certainly an internal Espruino one).... I'll see if I can find out what it is - exactly one variable per call of the callback is getting lost. Posted at 2014-07-16 by @gfwilliams Wow, that was bad. There was a leak in I've fixed it now (so it'll be fixed in 1v68), and you'll be able to pick up the latest build via www.espruino.com/binaries/git/commits/f4de82e93f6efc911299b30293128c6b51999d20 in about an hour. Sorry about all that - I was pretty sure there wasn't an issue with something so simple (in fact I remember looking for a memory leak in GPS before so I'm amazed I didn't find this one at the same time). Posted at 2014-07-16 by Hardware_Hacks No problem you helped me plenty with the code nice to see that we've found something else to contribute to the project :) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2014-07-12 by Hardware_Hacks
Hi All,
I am running the following GPS code:
I'm seeing an error popup every so often (not every time the code runs) as shown below:
After leaving the code to execute I am eventually hitting:
And even later on:
Just wondering if anyone can see whats going wrong here? I assume it might be to do with the setTimeouts and then clearing them?
Beta Was this translation helpful? Give feedback.
All reactions