This shows you the differences between two versions of the page.
Next revision
|
Previous revision
|
manual:chapter6:system:cmd_newob [2021/10/02 06:54] jojo1973 created |
manual:chapter6:system:cmd_newob [2021/10/04 04:54] (current) jojo1973 |
<callout color="orangered" icon="fa fa-comment" title="Description"> | <callout color="orangered" icon="fa fa-comment" title="Description"> |
---- | ---- |
The ''NEWOB'' command replaces an object on the stack with a new copy of itself. The command may seem pointless, but it solves a very specific problem: creating a new copy of an object that originated in a larger composite object (such as a list) allows the garbage collection to __recover the memory associated with the larger object__ when that larger object is no longer needed. | The ''NEWOB'' command replaces an object on the stack with a new copy of itself.\\ |
| \\ |
| The command may seem pointless, but it solves a very specific problem: when an object originated from a larger composite object is extracted and put on the stack it contains a reference to the parent object; even if the parent object is ''[[manual:chapter6:stack:cmd_drop|DROP]]''ped from the stack it keeps on living in the RAM, occupying precious resources.\\ |
| \\ |
| A copy of the extracted object created by ''NEWOB'' breaks this link and allows the ''[[manual:chapter6:system:cmd_garbage|GARBAGE]]'' collection to recover the memory associated with the larger object once it is not needed anymore. |
</callout> | </callout> |
| |