WRT large memory allocation, try throwing a sys(1104) in maybe.
"Purges memory cached by programs and data, and clears and refreshes buffers for open tables. You can improve performance by calling SYS(1104) after executing commands that make extensive use of memory buffers. This function also clears internal buffers for open tables, forcing the tables to be refreshed, which is useful with large tables and in multiuser environments."