Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: monkey0506 on Fri 08/07/2005 14:20:29

Title: Struct limits....
Post by: monkey0506 on Fri 08/07/2005 14:20:29
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.
Title: Re: Struct limits....
Post by: Pumaman on Fri 08/07/2005 15:48:33
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.
Title: Re: Struct limits....
Post by: monkey0506 on Fri 08/07/2005 15:56:08
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.
Title: Re: Struct limits....
Post by: Pod on Fri 08/07/2005 19:02:08
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]
Title: Re: Struct limits....
Post by: scotch on Fri 08/07/2005 20:28:38
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.
Title: Re: Struct limits....
Post by: Pod on Fri 08/07/2005 20:34:13
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!
Title: Re: Struct limits....
Post by: HeirOfNorton on Sat 09/07/2005 01:43:57
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
Title: Re: Struct limits....
Post by: Pod on Sat 09/07/2005 13:04:28
Does "char strs[200][500][30]" crash it? [I know it's equvilant]
Title: Re: Struct limits....
Post by: DoorKnobHandle on Sat 09/07/2005 13:05:27
AGS currently does NOT support multi-dimensional arrays...
Title: Re: Struct limits....
Post by: Pod on Sat 09/07/2005 13:08:14
*slaps head*
Title: Re: Struct limits....
Post by: Pumaman on Sat 09/07/2005 16:55:35
Aha! I have finally managed to reproduce the problem, I'll get it fixed.
Title: Re: Struct limits....
Post by: Pod on Sat 09/07/2005 17:52:52
What WAS the problem then? :D
Title: Re: Struct limits....
Post by: monkey0506 on Sat 09/07/2005 23:13:19
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).