stack problem

Ellen De Beuckeleer ellen.debeuckeleer at incgeo.be
Tue Jul 12 13:48:15 UTC 2005


I thought it might be a good idea to summarise this entry:

1. I tried to enlarge the stack by doing one of the following, but it 
didn't  work:
- "-mmax-stack-frame=10000000" in CXXFLAGS. It doesn't work. Reason: 
"Maybe something like -mmax-stack-frame exists on obsolete targets, but 
for the common architectures it is long gone."
- ulimit -s unlimited in shell or in .bashrc: the problem remains. 
ulimit doesn't seem to have any effect??? no idea why :(

my conclusion: the stack is just to small and difficult (?) to enlarge. 
So, better be safe than sorry:

2. use the heap!
like indicated below. Problem solved (although minor changes had to be 
done...I'll face the consequences ;) )

Thanx for all your tips!

Ellen

ps: Does anyone know a good book/report/website/.... to learn more about 
handling large data?



Ellen De Beuckeleer wrote:

> I will certainly try this! Thanx.
>
> Reiner Beck wrote:
>
>> Ellen,
>>
>> trying to increase the stack size is the wrong solution for your 
>> problem. You should definitely try to reduce the size of your class, 
>> as was suggested in an earlier mail. Just try to imagine what happens 
>> if you copy the class over the stack (e.g. a "push_back()" in a STL 
>> vector) - looming disaster. And more pitfalls to discover ...
>>
>> Try to allocate the memory in the heap - the change in your code is 
>> not that big (even if you are supposed to change as little as 
>> possible: the change will be a big improvement):
>>
>> Example:
>> <code>
>> class MyClass
>> {
>> public:
>>   MyClass() :
>>      myArray(NULL)
>>   {
>>      myArray = new int[myconst];
>>      if (myArray == NULL)   // check if you got the memory
>>      {
>>         ::exit(1);   // or do something else
>>      }
>>   }
>>
>>   ~MyClass()
>>   {
>>      delete [] myArray;   // release the memory
>>   }
>>
>> private:
>>   int* myArray;
>>
>> };
>> </code>
>>
>> HTH
>> Reiner
>>
>>> Hi,
>>>
>>> I use some extremely large arrays like : int myArray[myconst] and 
>>> myconst can be eg. 1000000. My total amount of space required for an 
>>> instance of the class is about 26,6 MB. I am reusing code which I 
>>> have not written myself and I am not supposed to change to much.
>>>
>>> Ellen
>>>
>>
>> -
>> to unsubscribe from this list send an email to 
>> kdevelop-request at kdevelop.org with the following body:
>> unsubscribe »your-email-address«
>>
>>
>
> -
> to unsubscribe from this list send an email to 
> kdevelop-request at kdevelop.org with the following body:
> unsubscribe »your-email-address«
>
>

-
to unsubscribe from this list send an email to kdevelop-request at kdevelop.org with the following body:
unsubscribe »your-email-address«



More information about the KDevelop mailing list