Anonymous user
Memory allocation: Difference between revisions
→{{header|Smalltalk}}
Line 1,450:
{{works with|Smalltalk/X}}
To allocate a non-movable, non garbage collected block of memory
<lang smalltalk>handle := ExternalBytes new:size
...
handle free</lang>
To allocate a non-movable block of memory, which is garbage collected as soon as the reference is no longer reachable by Smalltalk (
<lang smalltalk>handle := ExternalBytes unprotectedNew:size
...
handle := nil "or no longer reachable"
...
Of course, both are to be used with great care, as memory leaks are possible. Thus, it is only used by core parts of the system, eg. for async I/O buffers, shared memory, mapped I/O devices etc. Normal programs would not use them.
|