XParser read-in buffer too small for large-scale 0.xml files #16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the error
Using a large-scale ABM, if there is an agent in the model that is accumulating a history of data in a dynamic array, then an error may occur if a snapshot is created after many iterations, and we try to read it in again to continue from the snapshot state. Or, a
0.xmlfile might also contain variables that are simply very large (more than 1,000 chars, which was the original buffer, or 100,000, which is the current buffer). This pull request introduces a global constant to set the buffer.The error message is:
Diagnosis
If the contents of a single memory variable (a static or dynamic array) exceeds 100 KB (100,000 chars), this exceeds the size of a read-in buffer in the file:
xml.tmpl.Cause:
This buffer is used when FLAME tries to read-in data from 0.xml file:
Solution 1:
In file:
xml.tmpl, increase the buffer for reading in static and dynamic arrays by a factor of 10, to 1,000,000 chars, or 1 MB.In these functions:
increase this buffer:
Solution 2:
In function
readAgentXML(), increase the buffer for reading in the agents and variables by a factor of 10, to 1000000 chars, or 1 MB:NOTES
Solution 3:
Define a constant buffer size at the top of the file
xml.tmpl:This is to be used for both the static and dynamic array data and the buffer:
char arraydata[100000]char buffer[1000000]