On Aug 5, 2006, at 12:52 PM, Thomas Moore wrote:
I have just tried recompiling an old program in RB2006r3 (Mac OSX
10.4.7) and got a compiler error message that I have not seen before:
"This method uses 32k of stack space, but the limit is 32k". (I get
the same message in 2006r2, can't check for versions before that.) Is
this a new limitation, or a bug? Is there a workaround or a way to
increase this limit? I don't think that it will be easy to rewrite the
method so that it uses less stack space (not even sure how to
begin...)
1 - Reuse variables. For example
Version 1
Dim i As Integer
Dim sum As Double
Dim avg as Double
sum = 0
For i = 1 to 10
// Do something with 'i'
sum = sum + // whatever using 'i', usually an array of some sort.
Next
avg = sum / 10
sum = 0
// Some other code
For i = 17 to 207
// Process these cases...
sum = sum + // another 'whatever', again involving 'i'
Next
avg = sum / ((207 - 17) + 1)
is better than:
Version 2
Dim i As Integer
Dim sum1 As Double,sum2 As Double
Dim avg1 As Double,avg2 As Double
sum1 = 0
For i = 1 to 10
// Do something with 'i'
sum1 = sum1 + // whatever using 'i', usually an array of some sort.
Next
avg1 = sum1 / 10
sum2 = 0
//Some other code
Dim j As Integer
For j = 17 to 207
// Process these cases
sum2 = sum2 + // another 'whatever', again; this time using 'j'
Next
avg2 = sum2 / 10
local variables use stack space.
2 - Re-factor the code. Grab common bits in the method, and put them in
their own methods. Repeated calculations with only slight variations in
the variables used are a good candidate for their own method.
3 - Put some of the more used variables as protected/private properties
in the class or module where the method exists.
Any help would be appreciated! Thanks, Tom Moore
-------------------------------------------------------------
This message has been scanned by Postini anti-virus software.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
William H Squires Jr
4400 Horizon Hill #4006
San Antonio, TX 78229
[EMAIL PROTECTED] <- remove the .nospam
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>