Due to a fundamental design flaw in the Regina REXX interpreter's design, it can leak memory. When I developed Reginald, one of my very first priorities was to completely rework the Regina sources to eliminate all memory leaks. Let's take an example script, and demonstrate the difference between Reginald and Regina in this regard.

Note: This article tests Regina version 3.2. But the test script is provided below, and the tool to measure the memory usage is available to any Windows 2000/XP user. So you can conduct these tests upon your own versions of Regina and Reginald.

/* Test script 1 */
i = 1

again:
  SIGNAL ON NOVALUE NAME oops
  IF (i // 1000) = 1 THEN SAY "Loop #"||i
  i = i + 1
  PARSE SOURCE err /* This raises NOVALUE, and causes a SIGNAL to "oops" */
  CALL sub(p)
here:
  IF i < 1000000 THEN SIGNAL again
EXIT

oops:
  /* Just continue our above loop after SIGNALing here, but with leaked memory under Regina */
  SIGNAL here

sub:
  RETURN
The above script loops around indefinitely (until you abort it by pressing CTRL and C keys simultaneously). Upon every 1000 iterations of the loop, the script prints out how many total iterations have been executed (just so you can visually see how many loops have been executed). So, as the script is looping around, you see it slowly counting out each 1000 iterations.

It is a fairly simple and pointless script, except that it does do one peculiar thing. It traps the NOVALUE condition on each iteration, and then causes that condition to be raised (by using a variable that hasn't been assigned a value). So, the script ends up doing a SIGNAL to somewhere else in the loop upon every iteration. This is important to demonstrate Regina's memory leak because any time you use a SIGNAL, EXIT, or RETURN instruction, or trap some condition via SIGNAL, Regina will likely leak memory.

First, let's run the above test script using Reginald. Run Reginald's Script Launcher (ie, RXLAUNCH.EXE) and pick out this script to run. While the script is running (ie, displaying its loop iterations), bring up the Windows Task Manager. (ie, Press CTRL-ALT-DEL to bring up the Windows 2000 Security Manager, and click upon the Task Manager button). Find the name of Reginald's Script Launcher in the list of processes. That would be RXLAUNCH.EXE. Now observe the memory usage while the script is running. Reginald will allocate a little bit of memory to manage some variables and other structures, but then memory usage will quickly level off and remain at that one level. After all, the script is not really doing anything to cause any memory allocation.

Above, Reginald's memory use after 14 seconds. It's about 2,000 bytes.

Above, Reginald's memory use is still about 2,000 bytes after an hour of running the script. In other words, no additional memory has been used.

Now, let's run the above test script using Regina. Run Regina's frontend (ie, REGINA.EXE) and specify this script to run. While the script is running (ie, displaying its loop iterations), bring up the Windows Task Manager. (ie, Press CTRL-ALT-DEL to bring up the Windows 2000 Security Manager, and click upon the Task Manager button). Find the name of Regina's frontend in the list of processes. That would be REGINA.EXE. Now observe the memory usage while the script is running. Regina will allocate a little bit of memory to manage some variables and other structures, but due to Regina's memory leak, Regina's memory usage will increase indefinitely until the system eventually runs out of memory and starts to tap into the hard drive virtual memory. Eventually it will consume even this and the Windows 2000 will have to rudely terminate Regina. (It is suggested that you press CTRL and C before that point. When you've seen enough, stop Regina before the operating system has to).

Above, Regina's memory use after 21 seconds. It has already climbed to over 10,000 bytes, and shows no signs of slowing down.

Above, Regina's memory use after 2 minutes. It has climbed to over 40,000 bytes, and still no signs of slowing down.

Above, Regina's memory use at 5 minutes. It has climbed to over 70,000 bytes, and still no signs of slowing down. Etc.

You may wonder if the memory leak is present only in the Windows version of Regina. The answer is no. In fact, the latest versions of Windows employ an intelligent scheme to swap out rarely accessed memory to the virtual space on the hard drive, and thereby shift some of Regina's leaks into the swap file. (So, you may see the memory usage abruptly drop every so often, even though memory is constantly being leaked). After all, since Regina's leaked memory is lost, it is therefore never accessed and a prime candidate to be swapped to the hard drive. Upon other operating systems where that leaked memory is never shuffled off to a swap file, Regina's memory leaks may have an even more pronounced effect upon other running software and the system than does the Windows version.

And the memory leaks are even worse if you're writing a C/C++ program that calls the RexxStart() SAA API to run REXX scripts, because the leaks from all scripts accumulate.