previous next top contents index framed top this page unframed
Figure 32–25. $clearStrSpc
| PROCEDURE $clearStrSpc (POINTER($area) area); |
$clearStrSpc clears only the STRING space part of area. area's STRING space is cleared (i.e., converted to empty STRING space, not free pages); the effects of subsequently accessing the text of STRINGs that referenced area at the time $clearStrSpc was called are undefined.
One use of $clearStrSpc is shown in Example 32–26. The contents of a large ARRAY of REAL numbers are to be written to a file in a particular format (no exponent, six digits after the decimal point). Calling cvs many times to write a number in this format uses a lot of STRING space, but each STRING is used just once; it is created, written to the file, and then never used again. The code in Example 32–26 clears the STRING space of the area Foo after every hundredth STRING written, so that no more than a hundred numbers' worth of STRING space is in use at any time. $clearStrSpc executes fairly quickly, so it is not unreasonable to call it after every hundredth STRING is computed.
A call to $clearStrSpc cannot trigger a garbage collection.
Example 32–26. Use of $clearStrSpc
| INTEGER i; LONG INTEGER ii; POINTER($area) myArea; REAL ARRAY(1L TO 100000L) rAry; POINTER(textFile) f; ... area := $newArea("Foo",$noCollectablePtrs! $noCompactablePtrs!$noCollectableStrs,2000L); i := 0; FOR ii := 1L UPTO 100000L DOB write(f,cvs(rAry[ii],fixed!'6,myArea),eol); IF i .+ 1 = 100 THENB i := 0; $clearStrSpc(myArea) END END; $disposeArea(myArea); |
Figure 32–27. Effects of $clearArea and $clearStrSpc
![]() |
MAINSAIL Language Manual, Section 32.27