Page 1 of 1

Stack

PostPosted: Dec 19, 2003 @ 1:42am
by Dan East

PostPosted: Dec 19, 2003 @ 4:21am
by fzammetti
I'm not sure the direct answer to your question Dan, but I recall something about 32MB total for all stack space across all processes. Is it possible that your 2MB allocation is overrunning THAT limit, even if 2MB would otherwise be OK?

As for gracefully reporting stack out of space, I'm very surprised it's not throwing a system access violation. I believe that's what's supposed to happen when stack space is exceeded (I'm trying to remember some details that I caught some months ago looking through TechNet docs, so I may be way off in this). I know the OS should terminate your app, I'd bet that's happening, I'm just wondering if there's a way to trap the fault, maybe even with an external app. At least then you'd know it was a stack out of space issue.

PostPosted: Dec 19, 2003 @ 4:50am
by yuit
I've had this problem as well.

I had an array of wchar_t [10*1024] and my app would randomly crash. I changed the declaration from:

wchar_t buffer[10*1024]; to

malloc (sizeof(wchar_t) * 10 * 1024)

which seems to have solved the problem.

PostPosted: Dec 19, 2003 @ 7:40am
by Dan East

PostPosted: Dec 19, 2003 @ 8:33am
by Kzinti

PostPosted: Dec 19, 2003 @ 9:30am
by Conan

PostPosted: Dec 19, 2003 @ 12:25pm
by ppcStudios
Datatype misalignment issues can be very common - Warlords II had a ton of them crop up. And they cause some of the goofiest bugs and crash issues you could ever imagine.

Sometimes you get lucky and eVC will tell you there is a Datatype Alignment error (if you are debugging directly on the device) but for the most part you'll need to dissect your structs and either align them by padding or #pragma pack'ing them.

I can't say for sure that allocating a 2MB block of memory won't fail (as I've never tried it), but if new or free doesn't fail then its a pretty good bet its allocating it properly. Warlords II has some pretty healthy chunks of memory allocated at startup, but certainly not 2MB continguous.

Dan, you're not allocating this as a global variable are you? I found serious problems using large data chunks as globals on the PPC and they involved running into memory limitations on the devices (I don't remember offhand what the problem was, but I may have written it down somewhere - I'll look today).

PostPosted: Dec 19, 2003 @ 4:39pm
by Exocet

PostPosted: Dec 19, 2003 @ 7:20pm
by refractor