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

Working With Memory Constraints

ANSWERED

Hello all,

 

I have never had to work within memory constraints before developing my FitBit app.  Before I published I decided to checkout how much memory this thing actually used.

 

I noticed that my memory is slowly ticking up and up by about 40 every second.  Obviously this is not ideal because if the user leaves the app running for a while I don't want it to crash.

 

I have no idea what to look for when finding the memory issue... I made sure I have no variable declarations (let, const, var etc) in loops, but what else should i be looking for?

 

Could clock.ontick or setInterval have anything to do this?  What else should I be looking for?

 

 

Thanks in advance!

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

The memory will tick up but then get cleared by the built in garbage collector; at least that is what I observed working on my apps/faces.

View best answer in original post

Best Answer
0 Votes
6 REPLIES 6

The memory will tick up but then get cleared by the built in garbage collector; at least that is what I observed working on my apps/faces.

Best Answer
0 Votes

 It looks to me like nothing is ever getting cleaned up and the memory usage just keeps growing indefinitely.

Best Answer
0 Votes
Hmmm... Did you get the dreaded Jeeryscript out of memory error? Can you
post your sample code to github so we can see what it's doing?
Best Answer
0 Votes

Well I feel silly now!  I was watching my memory use tick up every second and I guess I didn't watch it long enough to see Garbage Collection actually happen! 

 

Seems like everything is okay after all.

 

Thank you for the help!!

Best Answer
0 Votes
No problem! It's a good thing if you don't have to race it, like I'm
starting to do.
Best Answer

I was about to ask how you monitored the memory of your app because I recently hit the limit in mine, but then I found it, so I'm posting it here for anyone who has the same question: https://dev.fitbit.com/build/reference/device-api/system/#interface-memory


The emulator doesn't show your memory usage. I think it would be nice if it did. But a console log is almost just as good.

 

import { memory } from "system";
console.log("JS memory: " + memory.js.used + "/" + memory.js.total);
Best Answer