• Tags
  • Documentation
  • Order
  • Register
  • Login
Duet3D Logo Duet3D
  • Tags
  • Documentation
  • Order
  • Register
  • Login

Do variables need to be freed?

Scheduled Pinned Locked Moved
Gcode meta commands
3
6
300
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • undefined
    OwenD
    last edited by 10 Mar 2021, 19:59

    Now that variables have arrived (I'll have to wait till the weekend to play), I was just wondering if there might be any "gotchas" with regards to memory allocation.
    So a few questions

    • Are there likely to be any memory issues on Duet2 or other boards that are close to the limit?
    • Are local variables automatically freed at the end of a macro or print file?
    • In the case of global variables, what happens if for example M98 P"0:/config.sys" is run and it contains global variables?
    • Any other areas to consider?
    undefined 1 Reply Last reply 10 Mar 2021, 20:03 Reply Quote 0
    • undefined
      dc42 administrators @OwenD
      last edited by 10 Mar 2021, 20:03

      @OwenD said in Do variables need to be freed?:

      • Are there likely to be any memory issues on Duet2 or other boards that are close to the limit?

      Yes if you create a lot of variables, especially variables with string values. Most likely to be an issue on Duet WiFi/Ethernet with 12864 display configured. M122 displays a new Heap status line in the Platform section, which shows how much string heap is being used.

      • Are local variables automatically freed at the end of a macro or print file?
        Yes.
      • In the case of global variables, what happens if for example M98 P"0:/config.sys" is run and it contains global variables?
        You will get an error message for each one, because the variable is already defined.
      • Any other areas to consider?

      None that I can think of.

      Duet WiFi hardware designer and firmware engineer
      Please do not ask me for Duet support via PM or email, use the forum
      http://www.escher3d.com, https://miscsolutions.wordpress.com

      undefined 1 Reply Last reply 5 Apr 2021, 09:03 Reply Quote 0
      • undefined
        o_lampe @dc42
        last edited by 5 Apr 2021, 09:03

        @dc42 said in Do variables need to be freed?:

        @OwenD said in Do variables need to be freed?:

        Are there likely to be any memory issues on Duet2 or other boards that are close to the limit?

        Yes if you create a lot of variables, especially variables with string values. Most likely to be an issue on Duet WiFi/Ethernet with 12864 display configured. M122 displays a new Heap status line in the Platform section, which shows how much string heap is being used.

        I just compared the M122 output of my Duet2 (w/o LCD) and the Maestro (with 12864 LCD) and I couldn't find a difference in the Platform/Heap line?

        Heap OK, handles allocated/used 0/0, heap memory allocated/used/recyclable 0/0/0, gc cycles 0
        

        I also saw Platform/available RAM. Is that the max. memory we can play with in Meta-code macros?

        undefined 1 Reply Last reply 5 Apr 2021, 09:39 Reply Quote 0
        • undefined
          OwenD @o_lampe
          last edited by 5 Apr 2021, 09:39

          @o_lampe

          The values will change as you add variables to the heap.

          These are three outputs on my printer after adding additional variables
          (Duet 2 wifi with PanelDue 7i)

          Heap OK, handles allocated/used 99/9, heap memory allocated/used/recyclable 2048/994/870, gc cycles 21
          
          Heap OK, handles allocated/used 99/11, heap memory allocated/used/recyclable 2048/1150/1010, gc cycles 21
          
          Heap OK, handles allocated/used 99/13, heap memory allocated/used/recyclable 2048/1312/1150, gc cycles 21
          
          undefined 1 Reply Last reply 5 Apr 2021, 09:48 Reply Quote 0
          • undefined
            o_lampe @OwenD
            last edited by 5 Apr 2021, 09:48

            @owend
            👍
            Then the 12864 LCD only eats Duet2 memory, because it's not natively supported, as it is by Maestro?

            undefined 1 Reply Last reply 5 Apr 2021, 10:17 Reply Quote 0
            • undefined
              dc42 administrators @o_lampe
              last edited by 5 Apr 2021, 10:17

              @o_lampe said in Do variables need to be freed?:

              @owend
              👍
              Then the 12864 LCD only eats Duet2 memory, because it's not natively supported, as it is by Maestro?

              The 12864 LCD eats memory on any Duet now, however the Maestro has more free memory available to start with.

              Duet WiFi hardware designer and firmware engineer
              Please do not ask me for Duet support via PM or email, use the forum
              http://www.escher3d.com, https://miscsolutions.wordpress.com

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              Unless otherwise noted, all forum content is licensed under CC-BY-SA