NEW / DISPOSE and Memory Allocation

General discussions about working with the Astrobe IDE and programming ARM Cortex-M3, M4 and M7 microcontrollers.
Post Reply
Site Admin
Posts: 422
Joined: Fri Dec 31, 2010 12:30 pm

NEW / DISPOSE and Memory Allocation

Post by cfbsoftware » Thu Aug 09, 2012 8:32 am

In addition to its regular use with normal RAM, Astrobe for Cortex-M3 allows you to use the standard NEW function to create and access dynamic records and arrays using non-CPU RAM .

This was initially developed to allow Astrobe users better access to the peripheral RAM on MCUs (like the extra 16Kb + 16Kb of AHB SRAM on the LPC1769). However, it could also be used with any RAM that is directly addressable in the same way as CPU RAM. By allowing you to specify the base address of the heap this can be moved out of CPU RAM which then has the added advantage that there is more stack space available as well.

We have also implemented a new language extension, a standard procedure DISPOSE, to reclaim dynamic memory. This and the existing standard procedure NEW have been implemented in a new library module 'Storage' (inspired by a similar feature in Modula-2). Consequently, users with the source code of the library modules will now be able to substitute their own functions for the supplied memory allocation / deallocation procedures invoked by NEW / DISPOSE. As well as allowing you to tailor the performance and efficiency of these functions to suit the requirements of particular projects there are additional benefits e.g. you could add memory usage tracing features.

Post Reply