You are reading a single comment by @Robin and its replies. Click here to read the full conversation.
  • I changed a bit of my code, and now I am starting the function with 900 free blocks.
    I looked how much memory the function is using with E.getSizeOf() and got this:

    >E.getSizeOf(sendMainPage, 1)
    =[
      {
        name: "\xFFa",
        size: 1 },
      {
        name: "\xFFcod",
        size: 323 },
      {
        name: "\xFFlin",
        size: 1 }
     ]
    >E.getSizeOf(sendMainPage)
    =326
    //326 Blocks * 16 =  5216 bytes
    > 
    

    So the function is using 20% from the total blocks (1600) or 36.2% from all available blocks (900) of the ram without the CSS.
    But that's only the size when I request the page its using 430 blocks:

    //start of the function sendMainPage
    { "free": 895, "usage": 705, "total": 1600, "history": 85,
      "gc": 0, "gctime": 1.827, "blocksize": 16 }
    //after res.end();
    467
    >900-470
    =430 //blocks
    

    That's 47.7% of the free ram without CSS.
    I think I got something that could help (How to send a large amount of data faster ?). But I don't know how that should work with the long HTML string. It would be nice if you could help me with this.

  • Wed 2021.03.31

    post # 'What do you mean with this?'    ref: 'the 515 'usage' value'

    See 'usage' below heading 'Description'

    http://www.espruino.com/Reference#l_proc­ess_memory

    My intent was to make aware the amount of memory used by the actual code instructions initially uploaded. As no source code had been provided before that #5 post, I had no way of knowing whether additional code was being uploaded from the Left-Hand console side of the WebIDE.


    LAW of Unintended Consequences

    post #1 'I have a simple http server that responds with an 8KByte website'

    I mis-understood what task was being attempted while comparing your thread 'Is there a way to make a Basic Auth with the Webserver?' with this thread.

    See sample snippet below example function getPage()

    http://www.espruino.com/WiFi#using-wifi

    As in that example, I took that phrase to mean a Http Request whose fetched content responds with 8K and memory became full during reception. And as there was no objection to the addition of FRAM in post #2, continued down that line of thinking.


    A wild guess for post #6 last code block after heading 'This happens:' L3   might be that there is a missing trailing quote, mis-matched internal quote(s), improper nesting of quotes, missing semi-colon, etc.

    Has the use of a Html validator been tried?

    The use of base64 as @allObjects points out would assist in reducing those types of errors, but at the penalty of ~30% increase in string size.

    Try reorganizing memory:

    Definition of a flat string and example

About

Avatar for Robin @Robin started