mJS heap usage optimisation guidance

#1

Scripting, necessarily, occupies scarce heap resources. We are writing an application in mJS which is likely to grow as requirements change (they always do) and hence we want to be sure that we are architecting it, from the outset, to optimise heap usage, saving for the future :-).

Is there any written guidance anywhere on how to construct an mJS application such that it minimise heap usage?

Thinking along the lines of:

  • separation of code into different .JS files and how this influences heap usage,
  • impact of ffi() calls under different circumstances (exactly when do they start occupying heap?),
  • impact of comments in code on heap usage,
  • how long can a function realistically be,
  • what prevents garbage collection,
  • etc.