Opened 8 years ago
Last modified 8 years ago
#4191 closed defect
[PATCH] Clever map updates for the AI — at Initial Version
Reported by: | Itms | Owned by: | Itms |
---|---|---|---|
Priority: | Release Blocker | Milestone: | Alpha 21 |
Component: | Core engine | Keywords: | patch |
Cc: | Stan | Patch: |
Description
The underlying issue for the memory crash everybody experiences is the update of the passability map for the AI.
It uses our custom ToJSVal
for Grid
s which does the following:
- Create a new array
- Allocate memory for it and copy the data from
m_PassabilityMap
- Set the
data
property ofm_PassabilityMapVal
to the new array - (Later the old value of
data
will be deleted by the GC since it is not used anymore)
Thus, in the specific case of the AI map, this is sub-optimal and causes the allocation of a large chunk of memory (the entire passability map, array of size width*height*size(u16)
) for nothing.
This patch adds a custom function that modifies the already allocated passability data. It also uses that method for the territory map, which is allocated the same way but causes less problems since it is far smaller.
Additionally, I propose to remove the function GetConnectivityGrid
which is not used by the AI and has the same flaw. If the AI needs such a grid in the future, it should work the same way as the passability and territory ones.
This fixes the memory crash I experience in large maps (like Stan's new Corinthian Isthmus(4)), but other people should also test it.
Change History (1)
by , 8 years ago
Attachment: | 0001-Remove-unused-function-for-the-AI-connectivity-grid.patch added |
---|