What is process.memory giving ? #3571
Replies: 12 comments
-
Posted at 2014-01-28 by @gfwilliams Yes, memory units of 20 bytes is right. Just for anyone else:
Note: I've discovered a bug here, which is that What I think is happening is that the script is being executed, and is generating variables/functions which are using up more space than just the individual characters. If you just had one function that wasn't executed then the situation would be a lot better. For instance:
So the code above (which, incidentally is 490 characters) uses 35 blocks in total which is 700 bytes. Of that:
You can type |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-01-28 by JumJum Thanks a lot for this interesting answer, its very late, I appreciate this. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-01-29 by @gfwilliams Hi, At the moment all the info I have is in the Performance page. I think to sum it up:
You can always look at the result of Can't think of much else right now... But if you post up your code then I might notice some way you could save space? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-01-29 by JumJum Hello,
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-01-29 by @gfwilliams Did you try all this with a version you compiled yourself from Git? As I said at the start, it turns out that the current version 1v47 has a bug where it reports the used memory incorrectly. When I try your function in a newer version it reports 26 memory units (=520 bytes) for Blinker. However: Looking at what's in Blinker, what happens is a new version of |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-01-29 by JumJum I have 1v47 from espruino/binaries on Espruino Board. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-01-29 by @gfwilliams I'm trying to tweet when new versions are available... Otherwise the next time you plug the board into the Espruino web IDE it should tell you :) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-06 by JumJum Gave it a new try and got these numbers:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-06 by @gfwilliams Hi. You can basically ignore 'history' now - process.usage is all you need. If you look at trace, each blinker is allocating:
So each new Blinker is a total of 36 blocks = 720 bytes. When you use require, you could try calling http://www.espruino.com/Reference#l_Modules_removeAllCached after instantiating all Blinkers? That'll probably free the cached module. IMO Espruino could do significantly better. If we added a Function.prototype.bind function you could skip defining the function inside |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-06 by user6350 To me is now becoming more clear how the Javascript interpreter works looking at how this simple example code has been parsed and put into memory structures.
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-06 by user6350 Possibly ESPRUINO software internal architecture is better than what can be expected after a first look. Assuming those SDRAM memory cost figures: expr 20 * 5450 = 109000 100KB/192KB SDRAM 92KB free STM32F4x7, x=0,1,2 a lot of possibility arise for the Javascript interpreter, whose memory allocation penalty is bigger for simple variables such a int, float but not for objects or functions. Has the capability of adding and removing cache modules been designed for such purposes or is there something more behind the scenes ? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-02-07 by @gfwilliams I'm not sure I understand. The Of course you could always just execute files directly with: Espruino was also designed with the possibility of automatically storing less-used data in slower memory - for instance the SD card. That would make it massively flexible - however it is yet to be implemented as for the uses that Espruino was designed for, 48kB of RAM actually goes a long way. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2014-01-28 by JumJum
process.memory() gives a total memory of 2000 and free of 1988 (after reset)
After sending a script with about 490 chars it gives free of 1841
Minifyied code has a length of about 270 and free returns 1875
How should I interprete this numbers, bytes seem to be a wrong, and memory units(20 bytes) would be a lot (3000 bytes for 490 chars of code for example) .
dump() did not help either
Beta Was this translation helpful? Give feedback.
All reactions