Most recent activity
-
- 14 comments
- 4,001 views
-
-
You where right @Gordon.
After I've updated the boot loader, the numbers are closer.Running the code:
> initial 694 1053 1053 1053 903 905 916
Running as an App
> initial 771 974 974 824 856 856
-
To give a bit of context: I would like the ability to list files present on the board.
I though it would be a small addition ton BangleApps to display such list, and allow to download them.I've mitigated the encoding issue:
// this is on the BangleApp: Puck.eval('require("Storage").list().map(encodeURIComponent)', (files,err) => { if (files===null) return reject(err || ""); files = files.map(decodeURIComponent) console.log("listFiles", files); resolve(files) });
-
Thanks for the clarification folks.
This final character makes
Puck.eval()
failing when transfering these strings:Puck.eval('require("Storage").list()')
will fail on:
Unable to decode "[\"+mclock\",\"-mclock\",\"*mclock\",\"+setting\",\"-setting\",\"=setting\",\"*setting\",\"+astroid\",\"-astroid\",\"*astroid\",\"+gpstime\",\"-gpstime\",\"*gpstime\",\"+compass\",\"-compass\",\"*compass\",\"+sbt\",\"=sbt\",\"+sbat\",\"=sbat\",\"+files\",\"-files\",\"*files\",\"+hrm\",\"-hrm\",\"*hrm\",\"+gpsinfo\",\"-gpsinfo\",\"*gpsinfo\",\".trishig\",\".bootcde\",\"+speedo\",\"-speedo\",\"*speedo\",\"@setting\",\"@activi\\1\",\"-activit\",\"+activit\",\"test\\1\"]\r", got SyntaxError: Unexpected number in JSON at position 357
Having chosen an octal escape sequence make it hard to (de)serialize.
-
Hi there!
Before opening a bug on the tracker, I wanted to double check this behaviour.
This code opens a file in append mode, and writes some text in it.const Storage = require('Storage') const name = 'test' Storage.erase(name) const file = Storage.open(name, 'a') console.log('-> files', Storage.list()) // file not in the list file.write('whatever') console.log('-> files', Storage.list()) // file exists, but has a \1 octal escape sequence appended to its name
this gives:
____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v04 (c) 2019 G.Williams >-> files [ "+mclock", "-mclock", "*mclock", "+setting", "-setting", "=setting", "*setting", "+sbt", "=sbt", "+sbat", "=sbat", "+files", "-files", "*files", ".trishig", ".bootcde", "@setting", ] -> files [ "+mclock", "-mclock", "*mclock", "+setting", "-setting", "=setting", "*setting", "+sbt", "=sbt", "+sbat", "=sbat", "+files", "-files", "*files", ".trishig", ".bootcde", "@setting", "test\1" ]
This
\1
at the end: is it expected?
Hello folks!
We may have a memory leak with
Module.removeAllCached()
, which is pretty ironic since I hoped to use it and free some memory ;PA bit of context. I'm trying various means to overtake the deadly 10000 character limit.
From the last month experiments, this is roughly the maximum number of symbols your application could have to fit in the Bangle's RAM.
I found a nice way to split my code into several chunks, each being a file.
My ES6 source code is leveraging dynamic imports, which instructs Rollup to produce several chunks.
A small Rollup plugin of mine turns the chunk into Bangle's files.
The app is written so screens are stored as files. Displaying a screen is simply requiring the relevant file, and calling the
build()
function it exposes.Here is the code,
and here is the minified, split output that you can run on your watch.
Now if you launch the app, and cycle through the various screens with middle button, at some point you should have a LOW_MEMORY error.
Since object returned by
require()
are cached, I've tried to callModule.removeAllCached()
after a screen was required, so it could claim the space from the previous screen.Here is the minified code, same as previously but with the call.
You'll be surprised to get the LOW_MEMORY error the very first time you load next screen.
Few more experiments makes me believe that
Module.getCached()
also have similar side effect.Could it be that listing cached modules (which
removeAllCached()
starts with) is eating more RAM that it should?