stack problem

Reiner Beck R.Beck at m4com.de
Tue Jul 12 09:51:50 UTC 2005


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«



More information about the KDevelop mailing list