RosettaCodeData/Task/Memory-allocation/OxygenBasic/memory-allocation.basic

35 lines
514 B
Plaintext

'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