• Is it normal that the values of the parameters of gps.connect are still keept?

    Yes, because of the scope chain from functions that you have defined in gps.connect.

    You could:

    • Define the functions outside, and just add them to the listeners by name
    • Set the parameters to undefined when you're done with them

    Again, is it normal that the comments at the top level are keept too?

    Yes, they're in history - the second Espruino runs low on memory it'll delete those.

  • Ok, that's clear now: I have to review the connect function and make it much more memory and time savy.
    The trace has no identified memory leak so far.
    It has been running for a few hours and the free memory is just changing by a few 10s of JsVar back and forth: I guess this is induced by the length of the nmea sentences.

    So far, the "compiled" functions have not been a problem since you solve the webide getting confused about the order of returned compiled function last week.

    edit: Here is a memory status taken from just after the trace(Serial4) to now.
    Apparently the size of gps and Serial4 are slowly changing, and getting smaller. I think this could be the result of some garbage collection...
    edit2: Actually, it is because the GPS lost its position fix and thus some properties of gps went to NaN and so on...
    edit3: It is worst than that: Serial4 is no more defined, I create a new psot about that

    >process.memory();
    ={ "free": 791, "usage": 1459, "total": 2250, "history": 569,
      "stackEndAddress": 536910664, "flash_start": 134217728, "flash_binary_end": 228576, "flash_code_start": 134449152, "flash_length": 262144 }
    >for (var i in global) print(i+" : "+E.getSizeOf(global[i]))
    Chrono : 108
    ddmmyy : 37
    E : 1
    secn : 41
    lln : 40
    cks7 : 27
    nmea_checksum : 54
    start_stop_nmea : 84
    fieldsOfInterest : 31
    codeFieldOfInterest : 44
    posFieldsOfInterest : 26
    getFieldsPos : 8
    parseHandlers : 124
    estimate_dist : 25
    tfTimeout : 1
    tf : 66
    connect : 183
    gps : 1997
    Serial : 6
    Serial4 : 1998
    console : 1
    Number : 1
    Date : 6
    Error : 6
    seconds : 1
    i : 1
    process : 1
    myInterval : 1
    ReferenceError : 6
    show : 10
    SyntaxError : 6
    =undefined
    GPS position fix from serial at 1442595640.43765068054
    We have a GPS position fix!
    GPS position fix from serial at 1442595666.95421600341
    We have a GPS position fix!
    GPS position fix from serial at 1442595752.85040473937
    We have a GPS position fix!
    >process.memory();
    ={ "free": 811, "usage": 1439, "total": 2250, "history": 283,
      "stackEndAddress": 536910664, "flash_start": 134217728, "flash_binary_end": 228576, "flash_code_start": 134449152, "flash_length": 262144 }
    >
    Disconnected
    >
    Connected
    >
    =undefined
    >
    =undefined
    >for (var i in global) print(i+" : "+E.getSizeOf(global[i]))
    Chrono : 108
    ddmmyy : 37
    E : 1
    secn : 41
    lln : 40
    cks7 : 27
    nmea_checksum : 54
    start_stop_nmea : 84
    fieldsOfInterest : 31
    codeFieldOfInterest : 44
    posFieldsOfInterest : 26
    getFieldsPos : 8
    parseHandlers : 124
    estimate_dist : 25
    tfTimeout : 1
    tf : 66
    connect : 183
    gps : 1719
    Serial : 6
    Serial4 : 1720
    console : 1
    Number : 1
    Date : 6
    Error : 6
    seconds : 1
    i : 1
    process : 1
    myInterval : 1
    ReferenceError : 6
    show : 10
    SyntaxError : 6
    JSON : 1
    =undefined
    >
    Disconnected
    > 
    
About

Avatar for Gordon @Gordon started