USER MANUAL CHAPTER 7 MEMORY MANAGEMENT SuperBASIC is privileged among QL jobs in that it is the only one which is allowed to shrink and expand its entire area to suit its needs. EXECutable jobs such as Q_Liberator object programs have to make do with a fixed job area allocated when they are started. If they require more storage then they must use the common heap. The common heap is an area of memory QDOS administers. When a job asks for some memory, QDOS splits off an area of the common heap for the job to use. When a Job is removed, any heap it has borrowed is returned to QDOS. If many jobs are running each using common heap, a problem called heap fragmentation can occur. This is when the heap is split into many small parts none of which are big enough for a given job to use. Q_Liberator is flexible about memory organisation. Object programs can be tailored to confine all data within a job's boundaries, or they can expand into the common heap as required. The choice can be made before a program is compiled by using a compiler directive or after compilation using the utility program QLIB_PATCH. OBJECT PROGRAM STRUCTURE A Q_Liberator object program consists of a code area and a data area. The code area contains the compiled form of the program and parameters associated with it. If you have linked in the runtime system or any assembler routines, then they too are contained within the code area. The data area, contains various control areas described below and storage for variables. Note that it is only the code area that occupies file space on a microdrive. However when the program is loaded into memory, there must be enough space to accommodate both the code and the data. The sizes of the code and data areas are printed at the end of a successful compilation. They can also be obtained by using QLIB_PATCH, whilst the total area occupied by a job in memory can be displayed by the procedure QJ. DATA AREA The following parts of the data area are of interest to the user because their size can be modified: Channel table The size of this table dictates the highest channel number that can be used within a program. It is sensible to keep channel numbers low because a 40 byte entry is reserved for all channels up to the highest which you specify. (This is also true for the interpreter). The number of channels is normally set automatically by the compiler. The minimum Page 41 of 100
USER MANUAL CHAPTER 7 MEMORY MANAGEMENT SuperBASIC is privileged among QL jobs in that it is the only one which is allowed to shrink and expand its entire area to suit its needs. EXECutable jobs such as Q_Liberator object programs have to make do with a fixed job area allocated when they are started. If they require more storage then they must use the common heap. The common heap is an area of memory QDOS administers. When a job asks for some memory, QDOS splits off an area of the common heap for the job to use. When a Job is removed, any heap it has borrowed is returned to QDOS. If many jobs are running each using common heap, a problem called heap fragmentation can occur. This is when the heap is split into many small parts none of which are big enough for a given job to use. Q_Liberator is flexible about memory organisation. Object programs can be tailored to confine all data within a job's boundaries, or they can expand into the common heap as required. The choice can be made before a program is compiled by using a compiler directive or after compilation using the utility program QLIB_PATCH. OBJECT PROGRAM STRUCTURE A Q_Liberator object program consists of a code area and a data area. The code area contains the compiled form of the program and parameters associated with it. If you have linked in the runtime system or any assembler routines, then they too are contained within the code area. The data area, contains various control areas described below and storage for variables. Note that it is only the code area that occupies file space on a microdrive. However when the program is loaded into memory, there must be enough space to accommodate both the code and the data. The sizes of the code and data areas are printed at the end of a successful compilation. They can also be obtained by using QLIB_PATCH, whilst the total area occupied by a job in memory can be displayed by the procedure QJ. DATA AREA The following parts of the data area are of interest to the user because their size can be modified: Channel table The size of this table dictates the highest channel number that can be used within a program. It is sensible to keep channel numbers low because a 40 byte entry is reserved for all channels up to the highest which you specify. (This is also true for the interpreter). The number of channels is normally set automatically by the compiler. The minimum Page 41 of 100
Q_Liberator%203.36Ch15%20manual.docx