Array size limit?

Started by HeirOfNorton, Mon 06/06/2005 02:02:08

Previous topic - Next topic

HeirOfNorton

Okay, I've tried searching through the archive but I haven't been to find an answer on this.
Is there currently a limit on the size of an array, either in the highest index or in total bytes? I'm currently working on a script module that will make use of some fair sized arrays, and will allow game authors to increase the size of thoses arrays if necesarry. I'm quite sure that the current limits (if any) are still more than enough, but I'd like to know for sure so I can include some error checking.

HoN

scotch

If you make an array locally in a function then it seems to cause a stack overflow if you set the size to ~1000.  If you create one globally, AGS doesn't seem to have a problem allocating a 20 million int array, I don't know what the limit is, but you'd probably hit the limits of system memory first (the 20 million int array made my game use 118mb ram, but it ran fine).


Pumaman

There is no fixed limit on the size of global arrays, but as scotch says they use up memory so don't go silly with creating massive ones unless you really need to.

HeirOfNorton

I now realize I probably should've specified that I am putting these arrays into a struct, in a script module. Not sure if that should make any difference, but..

I tried putting this code into the script header:

Code: ags

#define MAX_ONE 100
#define MAX_TWO 1000
#define MAX_ARRAY 100000  //MAX_ONE * MAX_TWO


struct MyStruct {
  char One[MAX_ONE];
  char TheOther[MAX_ARRAY];
};


(these are approximate, I'm on a different computer than I usually use.)

When I try to save the game, I get the following error message:
Exception 0x00000000 as EIP 0x00000000,
AGSEDIT v2.70.601, SIP=26)

Which I just noticed is the same error message that Rui keeps getting when he tries to delete his sprite folders (weird).

Through experimentation, I've discovered that this message only pops up if the two arrays combined are greater than 6 or 7 kb. However, just to see, I copied the above code into 2.62 and it compiles just fine. Also weird.

Anyway, that's what I've discovered. This new (apparently unintended) limit is smaller than I'd like, but larger than I'm likely to need. Thought you'd like to know about it.

HoN

Pumaman

That's bizarre. I just tried pasting that code into my script header and it compiled fine.

Does the crash happen every time you try?

HeirOfNorton

Yes, it happens every time, on that computer at least. I've just tried it on a different computer and it worked just fine. So, in all likelyhood, this is a hardware problem, though I have no idea what hardware problem could cause this. The one that gets the error is a PIII 750mHz with 512 MB of ram, about 3 gigs of free space, and WinXP.
Since you can't reproduce Rui's problem, could that be the answer for his issue as well?

Anyway, thanks for the help. I'll just have to develop the module on the other computer.

HoN

Pumaman

In all likelihood it is a bug in AGS, but a subtle random bug that's very hard to reproduce.

It could be for instance that the block of script you posted isn't the problem at all, but by putting it in it's somehow causing another problem to reveal itself.

If you'd like to upload your game source files for me, I can try and compile it myself and see if I can get it to crash.

HeirOfNorton

#8
Aha! Found the problem (on my end, anyway) This error occurs when I declare an instance of the offending struct in the global script, ie. "MyStruct Here;". With this in mind, I tried it again in 2.62 and it crashed there as well, with the following error message:

Exception 0xC0000005 at EIP=0xC005FE163, AGSE v2.62.509

This would seem to be some sort of limit on the size of a variable (or instance of a struct, or whatever). Again, it compiles just fine if the two arrays or reduced to make their combined size under about 6-7 kb, but it crashes consistantly otherwise.

(If this is a known and/or deliberate limit in AGS, allow me to officially request it be increased. .. ;D)

Huh, that's funny. If I make the instance an array, it compiles just fine. eg. With the above struct declared in the header, if I make a single instance:
Code: ags

MyStruct ThisStruct;

It crashes, but if I make an array of it:
Code: ags

MyStruct ThisStruct[200];

then it compiles just fine.

HoN

strazer

Hm, I thought this had been fixed? Or is it unrelated?

Pumaman

That's a known bug in 2.62, but it shouldn't happen in 2.7.

I tried putting the code you posted into my script header and global script, and it all compiled fine.

Has anyone else experienced anything like this with 2.7 ?

HeirOfNorton

#11
Nope, I still get the crash. I've tried it in a few different versions of AGS, on two different computers. Here's a link to a quick example game that'll crash for me:

http://www.freewebs.com/nortonian/crasher.zip

All I did here was create an empty game and put the offending code at the top of the global script (didn't even bother with the header). Just uncomment the "MyStruct thisStruct;" line.

Let's see if this makes any difference, or if it really does seem to just be me.

HoN

(Sidenote. I did have AGS 2.62 installed on both computers as well, in a different folder. Is there any way there could be some kind of conflict between them to cause the crash? I have noticed that I get the same list of "Recently edited games" whichever version I start (I assume because the list is stored in the registry...). Probably not, but I just thought I'd ask.)

Gilbert

Didn't crash for me, after uncommenting the declaration, works even after I changed it to thisStruct[1000] (tested using V2.7 Refresh 2).

Actually you can "install" as many versions of AGS in your computer as you want, as long as the files in each of the AGS folders are kept to the same version.
It's not a good practice if say, you have V2.62, and wants to "upgrade" it by just overwritting the old files with new files from the V2.7 package, chances are, some of the files didn't get overwritten for some reasons, and mixture of files from different version can cause confusing problems.
All should work fine as long as you always unpack an AGS package into a fresh new folder (unless it's a beta version where you really need old files).
If you're not sure, try unzipping V2.7 in another new folder, copy the game files there and try again.

By the way, how much memory do you have in your computers?

Pumaman

Hmm, didn't crash for me either, compiled fine.

Does anybody else get the crash when trying to compile this game?

strazer

No crashes here with v2.7 or v2.71 Beta.

HeirOfNorton

If it compiles okay for everyone else, I think we'll have to assume that it is something to do with my system, and not with AGS. (Although I find it very odd that it is happening on both my computers, as different as they are. I've even tried deleting AGS, doing a full registry clean, and reinstally it from scratch. Still crashed.)

Anyway, since it doesn't affect anyone else, and I can work around it easitly enough (by making each instance of the struct a part of an array, which I was most likely going to do eventually anyway), I'd say the problem can be set aside for now. Thanks to everyone for all the efforts, though.

HoN

SMF spam blocked by CleanTalk