Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

64KB heap size limit? Seriously?

 

const y = new Float32Array( 10000 );
console.log( x[0] );

The code above works. This code, however...

const y = new Float32Array( 10000 );
const y = new Float32Array( 10000 );
console.log( x[0], y[0] );

 ...gives JerryScript "out of memory" exception.

@JonFitbit JerryScript can support larger heap size, up to 512K in the same configuration with compressed pointers as you have in FitbitOS. Don't you think that 64K heap limit is too small? I just hit the limit in a real application, and this is the showstopper. Can it be increased? 

 

 

Best Answer
22 REPLIES 22

The most disappointing part was that I've got out of memory when attached kiezelpay to my app.

As Bill Gates said once, "640KB should be enough for everyone". Okay, I'm not asking for 640, but could you give us at least 512KB? SoC used in Ionic has about 2MB of RAM, and there is 21st century out there. 🙂

Best Answer

I fully agree with gaperton.
We cannot develop more complex apps, because of low memory.
Javascript is wasting a lot of memory and processor time too.
That's a big blocking point.

Best Answer

JerryScript VM designed by Samsung is in fact optimized quite well for the low memory consumption. One of the optimizations is 16-bit compressed pointers (and you can still have up to 512KB heap as pointers are 8-byte aligned). This VM is a very good choice IMO. Great technology.

But man, you really can't do a lot in 64K... It's a joke. And speaking of CPU usage - it seems that they use 64-bit floating point numbers while they have just 32-bit FPU. That's the real performance killer with JS VM. It's another problem which can be fixed with JerryScript settings, as it supports 32-bit floating point out of the box.

Best Answer

Another evidence.

const a = Array( 1000 );

for( let i = 0; i < 14; i++ ){
  a[ i ] = new Float32Array( 1000 );
}

Out of memory. i < 12 works fine. 1000 * 4 * 12 = 48000 bytes, allocation of 56000 bytes throws.

Now, the problem is that floating point number itself is the separate 8-bytes object in the heap. Which leads to interesting effects. This code works fine.

const a = Array( 4096 );

for( let i = 0; i < 4096; i++ ){
a[ i ] = true;
}

console.log( a[ 0 ] );

This code still works fine, because integers are packed inside of the array.

const a = Array( 4096 );

for( let i = 0; i < 4096; i++ ){
a[ i ] = 1;
}

console.log( a[ 0 ] );


This code, however, gives you out of memory. Why? Because your array already took 16Kbytes, and when you put float inside it instantly adds 32Kbytes to the heap (each float is 64-bit object). It means that theoretically, you can get out of memory in a computationally intensive task.

const a = Array( 4096 );

for( let i = 0; i < 4096; i++ ){
  a[ i ] = 1.5;
}

console.log( a[ 0 ] );

 

Solution? Never use arrays of floats. Use Float32Array instead.

So, fellas, how do you feel about SDK limits? They are closer than you might think, aren't they?

Think about that. 4K floating point numbers eats up the half of the available memory.

Best Answer

The device is resource constrained for various reasons. We can't support math heavy applications on device, but processing can be handled within the companion or cloud.

 

Are you trying to achieve a specific application, or just testing the limits of the platform?

 

Thanks

Best Answer
0 Votes

@JonFitbit I’ve got an out of memory exception in a real application with quite a modest functionality. To avoid that, I was forced to remove some features.

 

During investigation I have found that you’ve got 64K limit for the JerryScript heap, which is very low and I hope that the FitBit team would do their best to increase it to at least 128K for the apps (to be on par with Garmin). 64K is fine for watchfaces.

 

I left some examples here to demonstrate what 64K heap practically means. The last example with 4K floats is particularly interesting.

Best Answer

Hi @JonFitbit,
I've reach the limit easily by using the kpay library (~ 10Kb) and using some more complex UI with standalone data, like My Agenda.
It's not possible to just bet on the companion, because if you're phone is a bit away or just not responding, then you have no data or data after some long seconds. That's not what the user want to have.
Also the user wants to see different UIs - see an appointment alone for example in my agenda app. Or just have a longer list than 16 entries. It's not possible because every entry cost memory for UI and for data storage in the app. 
You will not recognize such limit if you only do a digital clock with date and fitness data, but for complex apps you'll reach this limit very quick.

Best Answer

> I've reach the limit easily by using the kpay library (~ 10Kb) and using some more complex UI with standalone data, like My Agenda.

 

Same here. Kpay and complex UI. And I don’t see any obvious flaws in kpay after examining its code.

Best Answer
0 Votes

If the 64Kb limit cannot be increased, then the device API must provide a lot more high level functionality. Then the user code can be decreased.

Best Answer

@gapertonwrote:

> I've reach the limit easily by using the kpay library (~ 10Kb) and using some more complex UI with standalone data, like My Agenda.

 

Same here. Kpay and complex UI. And I don’t see any obvious flaws in kpay after examining its code.


Exactly. JS is very memory expensive. The same code would be a tenth of its size when compiled in C (and runs in tenths of the time).
JS is great to print values in UI or files, but it's a mess to calculate with these values, because of the type safety.

Best Answer
0 Votes

High level API won’t save you from out of memory because of kpay, which seems to be caused by floats. And I can’t imagine an API which would reduce the size of my code calculating an average movement direction angle for the last 10 seconds. That’s, I would say, not trivial.

 

PS: In fact, I can :). Just left the definition in floating point math topic.

Best Answer
0 Votes

@gapertonwrote:

High level API won’t save you from out of memory because of kpay, which seems to be caused by floats. And I can’t imagine an API which would reduce the size of my code calculating an average movement direction angle for the last 10 seconds. That’s, I would say, not trivial.


I think of functionality like print a graph by giving tuples of data - if a Canvas object is not possible.
Or Text objects that scale the text byitself to a given width.
Or a List Object that draws a given array of something using a template for the entry.

Best Answer

Kind of a bit of topic: what is the kpay library? Thx

Best Answer
0 Votes
Best Answer
0 Votes

Thank you!

Best Answer
0 Votes

1981 called. They want their memory limitation back. 😉

Best Answer

I was quite surprised by the low level of watch faces for Fitbit... until I started playing with creating my own. Since for UI it's not possible to use even SVG polygons, developers are forced to use simpler elements, which means to we need use more of them to draw something useful. But of course this is quickly limited by super slow rendering, therefore quite static watch faces and lagging apps are the the final result. This is very frustrating, especially having the situation compared to Apple Watch.

Best Answer
0 Votes

your mistake is comparing apples with a popcorn. 🙂 

If you think of Fitbit as a very rudimentary OS that allows to create custom simple watch-faces and simple apps that were simply not possible before, it's definitively an OK platform plagued by what it seems slow progress.

If you start comparing this even with Pebble then you end up not being happy. I was hoping too Fitbit OS would be a Pebble with a better screen and the Fitbit ecosystem. I think it might be due to technical limitations (if you upgrade the screen on a Pebble you might not get the same battery life) or MVP shipping strategy. 

Best Answer
0 Votes

Any chance to have 128Kb of the heap for apps, at least? Like, okay, we've got Commodore 64 in a first generation of the hardware, that was fine. But a lot of time passed since then, now we have Elon Mask preparing the trip to Mars, and Versa 2 is out. Is it a time to make a bold move to Commodore 128 at least for Versa 2? It must have a new SoC with more memory nobody claimed yet, it should be ours ;).

Best Answer