The Sliding Heap module is  Steven Haslam 1992 and is distributed under the GNU Public Licence.   You will need the procedures in the SHeap BASIC library, or similar, to use it.

It creates and manages a sliding heap of blocks of memory, claimed from a program's Wimpslot as necessary, thus avoiding the fragmentation caused by repeatedly claiming and releasing memory from the RMA.
The module works under RISC OS 2 and RISC OS 31, and is compatible with RISC OS 35 and greater, and StrongARM, although dynamic areas can be used to perform the same task on such systems.