External stack

Contributions to this software library are always welcome. Please ensure that you post program listings rather than .raw files. They give a reasonable idea of what your program does without having to load them into a DM42 and you can also include comments in your code. Check out the following link for a decoder/encoder: https://technical.swissmicros.com/decoders/dm42/

You can then copy/paste the listing and post it in "code" tags.
Thomas Okken
Posts: 1100
Joined: Tue May 02, 2017 5:48 pm
Location: Netherlands
Contact:

Re: External stack

Post by Thomas Okken »

OlidaBel wrote:
Fri May 28, 2021 3:11 pm
Is there a way to clean the occupied memory, or is there a garbage collector in DMCP or in Free42 ?
RTN will clear the return stack, which includes all local variables. That should free up all the memory that was allocated by a recursive function.

There's no garbage collector in Free42, and none is needed, since objects are freed immediately when they are deleted using CLP, CLV, CLST, and RTN.
User avatar
OlidaBel
Posts: 58
Joined: Thu Mar 11, 2021 8:52 am
Location: Belgium

Re: External stack

Post by OlidaBel »

Thomas Okken wrote:
Fri May 28, 2021 10:59 pm
RTN will clear the return stack, which includes all local variables. That should free up all the memory that was allocated by a recursive function.

There's no garbage collector in Free42, and none is needed, since objects are freed immediately when they are deleted using CLP, CLV, CLST, and RTN.
OK.
The same Ack call on the iphone gives another error : "RTN stack full", then MEM give the same value as before, as you explain.
On the DM42 this is different, memory doesn't come back to the previous value after a Ack(4,1).
Before reloading a state (to get it fresh cleaned...), I just saved one State, and just after this, a MEM give me 71528 bytes back (I was blocked around 58976).
Very strange !
It's like the State Save command had clean the memory garbage.
---
Olivier
48GX, Prime G2, 50G, DM15L, DM42, 28S, HP 15c CE
Thomas Okken
Posts: 1100
Joined: Tue May 02, 2017 5:48 pm
Location: Netherlands
Contact:

Re: External stack

Post by Thomas Okken »

OlidaBel wrote:
Fri May 28, 2021 11:48 pm
Thomas Okken wrote:
Fri May 28, 2021 10:59 pm
RTN will clear the return stack, which includes all local variables. That should free up all the memory that was allocated by a recursive function.

There's no garbage collector in Free42, and none is needed, since objects are freed immediately when they are deleted using CLP, CLV, CLST, and RTN.
OK.
The same Ack call on the iphone gives another error : "RTN stack full", then MEM give the same value as before, as you explain.
That's normal; calculating ack(4, 1) requires a maximum stack depth of 65536 levels, and the stack in Free42 is limited to 1024. The DM42 runs out of memory before reaching the maximum stack depth, which is why you get a different error message there.
OlidaBel wrote:
Fri May 28, 2021 11:48 pm
On the DM42 this is different, memory doesn't come back to the previous value after a Ack(4,1).
Before reloading a state (to get it fresh cleaned...), I just saved one State, and just after this, a MEM give me 71528 bytes back (I was blocked around 58976).
Very strange !
It's like the State Save command had clean the memory garbage.
That sounds like a DM42 issue, then...
Post Reply