You are reading a single comment by @DaveNI and its replies. Click here to read the full conversation.
  • I have been really pleased with how much code I can load/run within 48K ram. My current project is getting quite large yet when using minification I still have room for 700 variables.

    I would still like to ensure I use as little memory as possible (just in case I hit the limit).

    Minification works really well but for those variables that the minifier cannot rename i.e. those that interface with the object (at root level) what length should I try to keep variable names to?

    i.e. what are "Short" variable names - I saw this mentioned somewhere but can't find it again?

    If I have a module defining an object/class of which there will only ever be one instance, is there any benefit (or overhead!) in having all functions against the objects prototype?

    I also tried placing all my main code within onInit(). i.e. instead of:

    var aaa, bbb, ccc;
    
    function one(){
    }
    
    function two(){
    }
    
    function three(){
    }
    
    onInit(){
          one();
    }
    

    I used:

    onInit(){
          var aaa, bbb, ccc;
    
          function one(){
          }
    
          function two(){
          }
    
          function three(){
          }
        
          one();
    }
    

    This allowed the minifier to rename most of my variables/functions but resulted in more memory being used - why did this happen?

    I have read http://www.espruino.com/Internals but not 100% sure about the best approach.

    Any other ideas on how to minimise memory usage yet keep my code readable/maintainable would be appreciated.

About

Avatar for DaveNI @DaveNI started