in my game when i call Bangle.buzz free memory keeps decreasing until it runs out of memory. I noticed in the documentation it says it returns a promise but i'm not familiar with them and i don't know how i should use Bangle.buzz so it does not keep eating free memoy or how to free the memory from probably the returned promise.
for example when testing i tried this code and it runs out of memory when doing this resulting in an error:
var memStart;
memStart = process.memory(true);
for(i = 0; i < 1000; i++)
{
Bangle.buzz(1,1);
var memTmp = process.memory(true);
var used = memTmp.usage - memStart.usage;
print(i.toString() + ": Udiff:"+ used.toString() + " used:" + memTmp.usage.toString() + " free:" + memTmp.free.toString() + " total:" + memTmp.total.toString() );
}
for(i = 0; i < 1000; i++)
{
Bangle.buzz(1,1);
var memTmp = process.memory(true);
var used = memTmp.usage - memStart.usage;
print(i.toString() + ": Udiff:"+ used.toString() + " used:" + memTmp.usage.toString() + " free:" + memTmp.free.toString() + " total:" + memTmp.total.toString() );
}
for(i = 0; i < 1000; i++)
{
Bangle.buzz(1,1);
var memTmp = process.memory(true);
var used = memTmp.usage - memStart.usage;
print(i.toString() + ": Udiff:"+ used.toString() + " used:" + memTmp.usage.toString() + " free:" + memTmp.free.toString() + " total:" + memTmp.total.toString() );
}
I'm not sure if i'm doing something wrong here but it shows something like this as a result
...
...
369: Udiff:11929 used:11972 free:28 total:12000
370: Udiff:11934 used:11977 free:23 total:12000
371: Udiff:11939 used:11982 free:18 total:12000
Execution Interrupted
at line 4 col 33
var memTmp = process.memory(true);
^
New interpreter error: LOW_MEMORY,MEMORY
>
>
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi,
in my game when i call Bangle.buzz free memory keeps decreasing until it runs out of memory. I noticed in the documentation it says it returns a promise but i'm not familiar with them and i don't know how i should use Bangle.buzz so it does not keep eating free memoy or how to free the memory from probably the returned promise.
for example when testing i tried this code and it runs out of memory when doing this resulting in an error:
I'm not sure if i'm doing something wrong here but it shows something like this as a result