syslib has three options for memory handling. The general routines are useable in all cases, but there are also provisions for user and heap memory, which can drastically reduce memory fragmentations, and are also somewhat faster (especially when releasing groups).
Of course there are also some routines for handling the memory.
Please note that memory management is very import when writing program (the choice of type of memory handling to use can influence the performance of your programs considerably). When a piece of memory has been allocated using one type of allocation routines, is should also be released by the same type, otherwise, your program may crash. Releasing an area of memory more than once can result in crashes. Please note that memory leaks are not as much of a problem in our part of the computing world. All memory owned by a job is always released when that job is removed (except for the SYSTEM job which can never be removed).
For efficienty, some extra routines are provided for allocating memory in heaps. This prevents memory fragmentation, memory is allocated faster, and all the memory in a heap can be released at once. The memory is not cleared when allocated (for speed).
The MEMHeap library is user code, therefore it is not atomic (and it is not written to be atomic because it is written for maximum speed). If the use makes atomicity necessary, wrap calls in MUTEXCall (cfr. mutex_h) routines. The Heap memory is always owned by the job which called MEMHeapInit. Care should be taken that the Heap memory is no longer available when it was released (possibly because the owner job is removed).
The heap which is referred to by a specific MEMHeap routine is always indicated by an id of type Heap.
For efficienty, some extra routines are provided for allocating fixed size memory chunks. To prevent memory fragmentation, this memory will be allocated in blocks (typically 100 chunks at a time). This memory can be allocated and released much faster than normal memory. The memory is not cleared when allocated (for speed).
The MEMUser library is user code, therefore it is not atomic (and it is not written to be atomic because it is written for maximum speed). If the use makes atomicity necessary, wrap calls in MUTEXCall (cfr. mutex_h) routines. The User memory is always owned by the job which called MEMUserInit. Care should be taken that the Heap memory is no longer available when it was released (possibly because the owner job is removed).
The user memory which is used is referred to by a specific MEMUser routine is always indicated by an id of type Chunks.