[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kdevelop
Subject:    Re: stack problem
From:       Reiner Beck <R.Beck () m4com ! de>
Date:       2005-07-12 9:51:50
Message-ID: 42D392B6.4010106 () m4com ! de
[Download RAW message or body]

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@kdevelop.org with the following body:
unsubscribe »your-email-address«
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic