__DialogScripts.asc: symbol table overflow - too many symbols defined

Started by Technocrat, Fri 20/02/2015 15:35:37

Previous topic - Next topic

Technocrat

Lately, I've been getting a technical issue with compiling my current project. The compilation process won't succeed, and presents me with the error:

__DialogScripts.asc: symbol table overflow - too many symbols defined

Once I delete a few scripts, GUIs and functions, it will compile again. I've found only two other references to an issue like this on the forums, and from what I can tell it seems to be related to just how darned big the game is getting; the globalscript is over 12000 lines long now, after all.

I'd like to know if there's a more long-term solution to this issue, as I'm running out of things that can be pruned to allow it to compile. Would it help to move some functions to another script? Will things like GUI buttons work if they're not in the globalscript? Where is this dialogscripts.asc, and is there something I can do to enlarge this "symbol table"?

Crimson Wizard

Gurok has just removed this limit in the AGS 3.4.0. This change be included in the next public release.

Quote from: Technocrat on Fri 20/02/2015 15:35:37
I'd like to know if there's a more long-term solution to this issue, as I'm running out of things that can be pruned to allow it to compile. Would it help to move some functions to another script? Will things like GUI buttons work if they're not in the globalscript? Where is this dialogscripts.asc, and is there something I can do to enlarge this "symbol table"?
The symbols are gathered from:
a) all the game objects (gui, characters, etc). You cannot do anything with them (except for deleting a few).
b) the built-in AGS functions and variables. You can do nothing with it.
c) functions and variables declared in all the script headers included (related or above the current script). If you have tonns of things declared in headers, consider rewriting your script in some way that would let you hide them in script body file.
d) functions and variables in current script (body). You may try splitting a script into several modules to reduce the number of symbols present in particular script.

Note: size of variables does not count, only number of unique names. So, array of 10000 elements and am "int a" take same place in the table of symbols.

On a side-note, "dialogscripts.asc" is an automatically generated script of all your dialogs. You cannot access it directly.

Technocrat

Ah thank you! I feel educated now.

I'm sure I can probably keep pruning until the next public release.

Dave Gilbert

Hi all. Sorry to drag up this old topic but I am very curious about this problem. We are still getting new assets (mostly music and sound) and we are fast running out of things to prune.

I am very confused because I have asked around and gotten the statistics of other "large" sized games, and the number of assets they contain often exceed the assets for Technobabylon. Which makes me think that we are doing something wrong.

I'd like some clarification on this:

Quoted) functions and variables in current script (body). You may try splitting a script into several modules to reduce the number of symbols present in particular script.

By "current script (body)" do you mean the global script? The one big difference between TB and other games of similar size is that TB doesn't use many modules. Is there anything else we could be doing to fix this? We launch in two months and this is a big hindrance.



Monsieur OUXX

Hi Dave,

I'm not an expert of how AGS compiles internally, but I know things about compilers and linkers in general.

"symbols" are the unique identifiers that the compiler gives to each, well, symbol, found in the game scripts. It's all about text, really. What's a symbol? It's any custom name, like a function or variable name. Every time the compiler's parser finds a new symbol, it stores it into a big table, and then when it finds another symbol with the same name, it looks up the table and tries to find out if it's the same one (it could be two variables with the same name, e.g. a global variable and a local variable, or even the name of one of the parameters inside the function being parsed).


Code: ags

// Here is an example of symbols nightmare for the compiler : Each
// time it has to lookup the symbols table to figure out which "a"
// we're talking about

int a; //a symbol: global variable

int a(int a) //two symbols: function name and parameter name
{
    int a; //one more symbol: local variable
    a=2;
    return a;
}

void game_start()
{
    int a = a(666);
}


So as you can imagine, the symbols table can grow up quite fast AND more importantly its size increase varies greatly depending on your code structure: As I said I don't know how AGS works specifically, but avoid all tricky things such as forward declarations, recursive functions, lots of homonymous variables, etc. because they can cause trouble to the AGS code that is in charge of maintaining and sorting out the symbols table. Even a code block inside a code block inside a code block etc. gives extra work to the compiler... and requires more memory space and entries in the symbols lookup table!

I'd say the general solution is to "split up things". I'm not necessarily talking about game resources (even though audio clips and such will be turned into symbols since they need to be accessed form the script), but really split the scripts. Make sure stuff is as local as possible and stored into separate files that will be processed separately.

For example, if you have lots of stuff declared and used in the global script, then move it to custom scripts AND make sure that as much stuff as possible is kept in the script body -- don't make it public (i.e. global) by putting everything into the header. I'd say, the compiler must be able to have finished parsing one script file before starting to parse the next one, without keeping a gazillion symbols in memory because they were public and might potentially appear in another script.

EDIT: it sounds like my post is focusing on symbopls that have the same name, but the problem remains exactly the same if they all have different names. The compiler requires as many entries in the symbols lookup table.
 

Crimson Wizard

I realized that it may be difficult to discuss those things abstractly, so I will illustrate what Monsieur OUXX said in his last paragraphs with following image:

Spoiler


[close]

The script headers, as well as global game objects (characters, inventory items etc) form a "pipe", where symbols fall down and accumulate at lower levels.
The script modules (what I called "script bodies") only get the symbols that fall from above and their respected headers. Room scripts also receive all symbols defined by the room (room objects, hotspots, etc).
You should also notice from this picture that the symbols declared only inside script modules (not headers) won't "fall down" to the next scripts.

If the number of accumulated symbols exceed certain limit, the aforementioned error occurs.

So, the idea is to decrease number of symbols accumulated at every single level.

Gurok

Literals also count as symbols and are probably the biggest offender in a lot of cases. I haven't tested this, but you could try putting longer dialogue responses into a method in a separate module and just calling the method from the dialogue script. Many symbols would be added to the symbol table for that module (e.g. DialogueResponses.asc) but only one would be added to the overall table (e.g. RespondToInterrogation).
[img]http://7d4iqnx.gif;rWRLUuw.gi

Radiant

Quote from: Technocrat on Fri 20/02/2015 15:35:37
Once I delete a few scripts, GUIs and functions, it will compile again. I've found only two other references to an issue like this on the forums, and from what I can tell it seems to be related to just how darned big the game is getting; the globalscript is over 12000 lines long now, after all.

Regardless, 12000 lines is well within the capabilities of AGS; for instance Heroine's Quest has over three times that amount. So I suggest that splitting the global script may actually resolve the issue.

And as the OP asked, yes, GUI buttons work just fine if they're in other scripts.

Monsieur OUXX

A very efficient solution was provided by Gurok, who noticed that the global script also "contains" all the game's dialogs -- hence gazillions of symbols that are just begging to be moved to a dedicated module.

The detailed solution:
http://www.adventuregamestudio.co.uk/forums/index.php?topic=51979.msg636510844#msg636510844
 

SMF spam blocked by CleanTalk