Allocating from the heap when a module is initialised
Posted: Fri Jun 26, 2015 12:03 pm
it took me a long time to fix a nasty problem that looked like memory being overwritten somehow. I found out that the overwritten memory -a record allocated on heap- was allocated during the MODULE Initialisation sequence before the body of MODULE Storage got called which reset the heap start address to its initial value. The result was that subsequent calls to NEW allocated same heap area already used by blocks allocated before initialisation of MODULE Storage! The cure was easy, moving 'Storage' in the IMPORT list helped. For the moment I import 'Storage' in MODULE 'Main'. Is this a foolproof scheme or do you recommend another solution?