Computer Science Canada

A new error! :)

Author:  copthesaint [ Mon Jun 07, 2010 11:19 am ]
Post subject:  A new error! :)

Ok, so for the first time ever, for my self, I have gotten an error that says:
Size of global variables is too big, so I'm guessing i'm sol? lol.

Author:  USEC_OFFICER [ Mon Jun 07, 2010 11:36 am ]
Post subject:  RE:A new error! :)

What number did you put in the variable?

Author:  DemonWasp [ Mon Jun 07, 2010 11:47 am ]
Post subject:  RE:A new error! :)

It seems like you're trying to allocate a global variable (probably an array) that's too large. Try putting the largest allocation you have inside a procedure instead (so that it's local to the procedure - I know this doesn't do what you want it to do, just do this as a test) and see whether it allows that.

If that doesn't work, try embedding the large array allocation inside a class built to handle that data structure. Allocate an instance of the class as a global, not the array itself. This will allocate that array on the heap, not in the data segment of your program in memory.

Author:  chrisbrown [ Mon Jun 07, 2010 12:17 pm ]
Post subject:  Re: A new error! :)

If this is related to what you described in the shoutbox, am I right in thinking that you are trying to model a physical environment as a 3D array of points/units? Because if so, that's a massive waste of memory. (If not, sorry for misinterpreting.)

Regardless, multidimensional arrays require a lot of careful planning to be both memory- and cpu-efficient. If you have many elements that are rarely/never accessed, you should probably look for an alternative solution.


: