Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Allocating memory at start of VisualC++.NET

Status
Not open for further replies.

shetlandbob

Programmer
Mar 9, 2004
528
GB
Hi again,

thanks for all the help so far.

Here's another one:

I've got a class which is set up and at the launch of my program I want to set up the following

Class myClass[MAX_NO_OF_CLASS];

However if I have the MAX_NO_OF_CLASS to high then the program crashes on launch with the following message:

Unhandled exception at 0x00420305 in Program.exe: 0xC00000FD: Stack overflow.

I've done a lot of testing of the program and checked my memory usage, its not very high so far, no way near the limit of my computer.

Any ideas on how I can get round this? As I havn't finished setting up my Class yet so I'm going to get into serious bother if I cant fix it.

Cheers
 
Use a CArray and add them one at a time. You can use pointers or if you have the copy constructor, objects declared on the stack.

Matt
 
I've never had a problem like that, but it sounds like there could be a problem with the class's constructor. Could you post the constructor's code?
 
Stack overflow is usually due to infinit recursive calls (well unless you actually do inanely large stuff on the stack).

/Per

"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."
 
Your computer's memory might have lots of room, but that doesn't mean the stack does. Try allocating your classes on the heap with new, or use a container that keeps its contents on the heap like CArray or std::vector.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top