I use Borland C++ 6, and there seems to be a bug!
I made a simple test program starting several threads, where each thread Execute function calls a recursive function which loops and makes some heavy allocation... (not)! Actually I narrowed it down to this, and it still gives EOutofmem exceptions!
Recurs is called from Execute.
int i has had values from 2-10 in a couple of tests when eoutofmem occurs, so the recursion hasn't got so far...
typedef AnsiString MyString;
int TTestThread::Recurs(int i)
try
{
int j = 0;
const int rmax = 20;
const int hmax = 350;
for(j = 0; j < hmax; j++)
{
MyString strTest2 = "test";
strTest2 += MyString("Random test: ") + "test3";
//OutputDebugString(IntToStr(j).c_str());
}
}
catch(Exception & e)
{
OutputDebugString(e.Message.c_str());
//ShowMessage(e.Message);
}
if(i < rmax)
{
Sleep(10);
i = Recurs(i);
}
else
{
i = rmax + 1;
//OutputDebugString("exiting recurs?");
}
return i;
}
Is this bug known and are there any workarounds?
I tryed using std::string instead, and that actually seemed to solve it, because no more exceptions of this kind ocurrs. But when I try to use it in my real project, which is based on an exe and several dlls, some other strange things occur (eg. memory access overruns in the std::string class functions - another bug in Borlands implementation or what??)
Best Regards,
Sebastian
I made a simple test program starting several threads, where each thread Execute function calls a recursive function which loops and makes some heavy allocation... (not)! Actually I narrowed it down to this, and it still gives EOutofmem exceptions!
Recurs is called from Execute.
int i has had values from 2-10 in a couple of tests when eoutofmem occurs, so the recursion hasn't got so far...
typedef AnsiString MyString;
int TTestThread::Recurs(int i)
try
{
int j = 0;
const int rmax = 20;
const int hmax = 350;
for(j = 0; j < hmax; j++)
{
MyString strTest2 = "test";
strTest2 += MyString("Random test: ") + "test3";
//OutputDebugString(IntToStr(j).c_str());
}
}
catch(Exception & e)
{
OutputDebugString(e.Message.c_str());
//ShowMessage(e.Message);
}
if(i < rmax)
{
Sleep(10);
i = Recurs(i);
}
else
{
i = rmax + 1;
//OutputDebugString("exiting recurs?");
}
return i;
}
Is this bug known and are there any workarounds?
I tryed using std::string instead, and that actually seemed to solve it, because no more exceptions of this kind ocurrs. But when I try to use it in my real project, which is based on an exe and several dlls, some other strange things occur (eg. memory access overruns in the std::string class functions - another bug in Borlands implementation or what??)
Best Regards,
Sebastian