Resolve error when loading a MapBasic application: "Unable to allocate memory. Unable to read application file."

Products affected: MapInfo Pro™, MapBasic™


When loading a MapBasic application, an error is generated: "Unable to allocate memory. Unable to read application file." even though the code has compiled.


The problem is caused due to a limitation on the symbol table and is not easily calculated or managed. A symbol table is a data structure where symbol names (Identifiers, function names), their type and scope etc are stored for the MapBasic interpreter. The limit is around 32608 bytes for a function within the symbol table.
It is related but not absolutely to the number of lines in procedure. For example an application keeps  saving and committing the same table it will not increase the symbol table size for the function but the application keeps saving and committing different tables this would increase the size.


UPDATED: December 4, 2019
To resolve cut the code into multiple sub procedures to manage the size.