-
November 7th, 2003, 12:22 AM
#1
Maximum size of Structure
Hi,
Is there a constraint on the maximum size of the Structure that can be defined in VC++.
Thanks in Advance,
Varadha
-
November 7th, 2003, 12:41 AM
#2
When i define the following struture
typedef struct summa
{
int a;
int b;
char c[1062144];
}summa;
and run the application, i get the following error.
Unhandled Exception: ..... Stack Overflow
-
November 7th, 2003, 12:44 AM
#3
This is because its too big for the stack. You could allocate it with new and put it on the heap instead. Or you could increase the size of your stack in the linker options.
Dave Mclelland.
-
November 7th, 2003, 12:51 AM
#4
Or use a std::string or std::vector<char> as a structure member, which essentially puts that memory on the heap.
What problem are you trying to solve, or is the question academic?
Jeff
-
November 7th, 2003, 01:20 AM
#5
Thanks Dave and Jeff, as u have said the problem is size of the structure is beyond the stack size.
How can i increase the stack size?
Can u give me some online tutorial on this.
-
November 7th, 2003, 07:43 AM
#6
Originally posted by Varadha
Thanks Dave and Jeff, as u have said the problem is size of the structure is beyond the stack size.
How can i increase the stack size?
Can u give me some online tutorial on this.
MSDN "Visual C++ Linker Options":
The /STACK option sets the size of the stack in bytes. This option is only for use when building an .exe file.
That said, usually when one thinks they need to increase the stack size, it is because they are abusing the stack (char c[1062144];). Rethink your design.
Thought for the day/week/month/year:
Windows System Error 4006:
Replication with a nonconfigured partner is not allowed.
-
November 7th, 2003, 09:33 AM
#7
[QUOTE]Originally posted by Andreas Masur
In is case I would rather say that he needs the 'Zm' option...
MSDN:
/Zm (Specify Precompiled Header Memory Allocation Limit)
Hi Andreas,
I'm ignorant. Can you explain how that pertains to this?
Thought for the day/week/month/year:
Windows System Error 4006:
Replication with a nonconfigured partner is not allowed.
-
November 7th, 2003, 09:37 AM
#8
Originally posted by Varadha
Thanks Dave and Jeff, as u have said the problem is size of the structure is beyond the stack size.
How can i increase the stack size?
Can u give me some online tutorial on this.
However, as the others also pointed out, you seem to be abusing the stack here, and should rather allocate that amount of memory on the heap instead of increasing the stack size. Besides that, what is the use of a structure that amount of memory as a static character array? You should rather rethink your design (or explain why you need to do this).
Last edited by gstercken; November 7th, 2003 at 09:39 AM.
-
November 7th, 2003, 09:52 AM
#9
Originally posted by vicodin451
I'm ignorant. Can you explain how that pertains to this?
No you don't...but I am stupid...forget about it, I was thinking about something different wile writing this...sorry about this...I already have deleted my nonsense...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|