Struct limits....

Started by monkey0506, Fri 08/07/2005 14:20:29

Previous topic - Next topic

monkey0506

What are the size limits for a struct?  I've encountered an error where it would seem that I need an array of 3000000 chars...o_0.  Or...I've just thought of a way around that, but I'd still like to know what the limits are.  Because trying to create an object with two char arrays of 3000000 objects keeps crashing AGS completely.

Pumaman

First of all, why on earth do you need an array of 3 million entries? There must be a better way to do what you're trying to accomplish.

Second, there is no fixed limit to array size. Assuming you're using 2.7, you should be able to create an array as large as you like (within the limits of available RAM). If you're getting a crash, please post about it.

monkey0506

Um...If my math is correct:

200 * 500 * 30 = 3000000

I don't have access to AGS now ATM, but I'll replicate this again when I do.  It's not a normal crash though...It's like, when I try to save, it says AGS encountered an error...this error was fatal...program pointer...was...  One of those, but at compile time.  That's when trying to create the object, i.e.:

struct mystruct {
  char strs[3000000];
  };

mystruct MyStructObj;

Or something like that.  I'm only about half awake now due to lack of sleep last night, and well, it seemed necessary at the time, but like I said, I found a way around that.

Pod

You do realise that's 3 gb's ?

Each char is 1 byte big. 3,000,000 of them would be 3,000,000 bytes - aka 3 Gb's [or just under if it's Gibi]

scotch

3 million bytes is 3 megabytes, well, a little less than.
It's not a totally insane amount of memory to use... but I can't think of many sensible reasons to do so in a game script.

Pod

Christ. sorry. I'm tired today, I keep making mistakes all over the shop.
I must have thought them 3,000,000 kilobytes or something. Argh, I dunno!

HeirOfNorton

Finally, it's happened to someone else!!

Sorry, I've had similar problems, un-reproduceable to anyone else (very aggravating).

Quote
struct mystruct {
  char strs[3000000];
  };

mystruct MyStructObj;

IF it is the same problem I have had, making the MyStructObj into an array should get rid of the crash (though it's still odd). Even an array of just a single element:

mystruct MyStructObj[1];

Don't know why. Don't even know why it crashes for me (and now possibly you) but no one else.

Hope this helps, cheers,

HoN

Pod

Does "char strs[200][500][30]" crash it? [I know it's equvilant]

DoorKnobHandle

AGS currently does NOT support multi-dimensional arrays...

Pod


Pumaman

Aha! I have finally managed to reproduce the problem, I'll get it fixed.

Pod

What WAS the problem then? :D

monkey0506

Glad to hear it.  Will it be fixed in the official version?  Seeing as the last time I tried to do something simple with the latest beta I crashed it...not sure what I was doing and/or why I didn't report it...  Oh well.

But yes, what was the problem?  As I need to create another large array for something else that is producing the same error (diff project).

SMF spam blocked by CleanTalk