Quote:
Tim suggested a good around (by using Threads), otherwise you could also programmatically set the stack size by using a declare to setrlimit.
Hello,
Thank you.
The sample application from previous post above dated "Sat May 18, 2013 8:53 pm" was updated with the following code to call the getrlimit and setrlimit functions on SuSE SLES 11 OS running on HP Proliant server. It was noted that the existing stack size was 8MBytes and this was increased to 64MBytes. However the sample application still had a stack overflow after 2082 Recursive calls even when the setrlimit reported success while setting stack size to 64MBytes. While in RB on Windows the same sample application has a stack overflow after 8402 Recursive calls.
Please see what mistake I may be making here.
Thanks and Regards,
Shahid.
Code below was added to the "Window1 Open Event" in the sample application from previous post above dated "Sat May 18, 2013 8:53 pm"
//
// Start of file.
//
#if TargetLinux
if (System.IsFunctionAvailable("getrlimit" , "libc") ) And (System.IsFunctionAvailable("setrlimit" , "libc") ) then
Soft Declare Function GetResLimit Lib "libc.so" Alias "getrlimit" (resource As Integer, rlim As Ptr) As Integer
Soft Declare Function SetResLimit Lib "libc.so" Alias "setrlimit" (resource As Integer, rlim As Ptr) As Integer
Dim RLIMIT_STACK As Integer = 3 // defined in 'resource.h'
Dim result As Integer
Dim StackSize As UInt32
Dim ReqStackSize As UInt32
//
// struct rlimit {
// rlimit_r rlim_cur; /* Soft limit */
// rlimit_t rlim_max; /* Hard limit (ceiling of rlim_cur) */
// };
//
Dim rlim As new MemoryBlock(8) // rlimit_t is of type unsigned integer, four bytes each
// 64 MB
ReqStackSize = 64 * 1024 * 1024
// 32 MB
//ReqStackSize = 32 * 1024 * 1024
result = GetResLimit(RLIMIT_STACK, rlim)
MsgBox( "result = " + Trim(Str( result)))
If result = 0 Then
StackSize = rlim.UInt32Value(0)
MsgBox( "Soft limit = " + Trim(Str( StackSize)))
MsgBox( "Hard limit = " + Trim(Str( rlim.UInt32Value(4))))
MsgBox( "Requested Stack Size = " + Trim(Str( ReqStackSize)))
If StackSize < ReqStackSize Then
rlim.UInt32Value(0) = ReqStackSize
result = SetResLimit(RLIMIT_STACK, rlim)
If result = 0 Then
result = GetResLimit(RLIMIT_STACK, rlim)
If result = 0 Then
StackSize = rlim.UInt32Value(0)
MsgBox( "Set Stack Size = " + Trim(Str( StackSize)))
Else
MsgBox( "Error: Reading of stack size failed.after setting stack size to " + Trim(Str(ReqStackSize )))
End If
Else
MsgBox( "Error: Setting of stack size to " + Trim(Str( ReqStackSize)) + " failed.")
End If
End If
Else
MsgBox( "Error: Reading of stack size failed.")
End If
else
MsgBox ("Can't find 'getrlimit' or 'setrlimit' in 'libc'")
end if
#endif
//
// End of file.
//