Task

Show how to explicitly allocate and deallocate blocks of memory in your language.

Show access to different types of memory (i.e., heap, stack, shared, foreign) if applicable.




 
'ALLOCATING MEMORY FROM DIFFERENT MEMORY SOURCES
 
sys p
 
 
static byte b[0x1000] 'global memory
p=@b
 
 
function f()
local byte b[0x1000]  'stack memory in a procedure
p=@b
end function
 
 
p=getmemory 0x1000 'heap memory
...
freememory p 'to disallocate
 
 
sub rsp,0x1000     'stack memory direct
p=rsp
...
rsp=p 'to disallocate
 
 
'Named Memory shared between processes is 
'also available using the Windows API (kernel32.dll)
'see MSDN:
'CreateFileMapping
'OpenFileMapping
'MapViewOfFile
'UnmapViewOfFile
'CloseHandle