Memory allocation: Difference between revisions
Content added Content deleted
m (Omit from Logtalk) |
No edit summary |
||
Line 637: | Line 637: | ||
By the typing rules of Haskell, w must have the type 'Ptr Word32' (pointer to 32-bit word), which is how malloc knows how much memory to allocate. |
By the typing rules of Haskell, w must have the type 'Ptr Word32' (pointer to 32-bit word), which is how malloc knows how much memory to allocate. |
||
=={{header|Icon}} and {{header|Unicon}}== |
|||
Icon and Unicon provide fully automatic memory allocation. Memory is allocated when each |
|||
structure is created and reclaimed after it is no longer referenced. For example: |
|||
<lang unicon> |
|||
t := table() # The table's memory is allocated |
|||
#... do things with t |
|||
t := &null # The table's memory can be reclaimed |
|||
</lang> |
|||
For structures whose only reference is held in a local variable, that reference is removed |
|||
when the local context is exited (i.e. when procedures return) and the storage is then |
|||
available for reclaiming. |
|||
The actual reclamation of unreferenced structures takes place when garbage collection occurs. |
|||
=={{header|J}}== |
=={{header|J}}== |