AMAI
AMAI copied to clipboard
Various local handle variables not being cleaned up to avoid resource leaks
like this
function SelectUnittype takes group g, unittype typ, boolean is_of_type returns group
local unit u = null
local group rg = CreateGroup()
loop
set u = FirstOfGroup(g)
exitwhen u == null
if IsUnitType(u, typ) == is_of_type then
call GroupAddUnit(rg, u )
endif
call GroupRemoveUnit(g, u )
endloop
call DestroyGroup(g)
return rg
endfunction
takes group g local group rg returns group rg
here call DestroyGroup(g), so g is excretion success in SelectUnittype then in function XXXX there call SelectUnittype , if DestroyGroup(g) again , the g != rg , and Destroy fail? excretion fail?
Same question Exist in Location like
function GetSubtractionLoc_dd takes location l1, location l2 returns location
local real locX = GetLocationX(l1) - GetLocationX(l2)
local real locY = GetLocationY(l1) - GetLocationY(l2)
call RemoveLocation(l1)
call RemoveLocation(l2)
return Location(locX, locY)
endfunction
returns is locX and locY
but we cannot know location l1 and location l2 will it continue to be used , so we cannot call RemoveLocation(l1) ,set l1 = null
and this , know location l1 and location l2 no longer needed ,so RemoveLocation, but call RemoveLocation(l2) , why have not set l2 = null ? intended?
function GetSubtractionLoc_dd takes location l1, location l2 returns location
local real locX = GetLocationX(l1) - GetLocationX(l2)
local real locY = GetLocationY(l1) - GetLocationY(l2)
call RemoveLocation(l1)
call RemoveLocation(l2)
return Location(locX, locY)
endfunction
function GetSubtractionLoc_kd takes location l1, location l2 returns location
local real locX = GetLocationX(l1) - GetLocationX(l2)
local real locY = GetLocationY(l1) - GetLocationY(l2)
call RemoveLocation(l2)
return Location(locX, locY)
endfunction
last , in Blizzard.eai
local button b = GetClickedButton()
local trigger t = CreateTrigger()
so many ,and no excretion
I'm afraid that why the game will stuck
The method ends with _dd or _kk or _kd which means _dd Destroy both locations _kd Keep first location, destroy second
have to use the method based on what is required in the calling logic.
You are correct we are missing reset of local handle variables to null so there are leaks ongoing. Triggers and dialogs are not cleaned up at all in the commander.
Alot of locations and groups were cleaned up a long time ago using a tool to detect the leaks automatically as it ran. That tool no longer works though.
The method ends with _dd or _kk or _kd which means _dd Destroy both locations _kd Keep first location, destroy second
have to use the method based on what is required in the calling logic.
You are correct we are missing reset of local handle variables to null so there are leaks ongoing. Triggers and dialogs are not cleaned up at all in the commander.
Alot of locations and groups were cleaned up a long time ago using a tool to detect the leaks automatically as it ran. That tool no longer works though.
24 player map still caton , even collapse
The method ends with _dd or _kk or _kd which means _dd Destroy both locations _kd Keep first location, destroy second have to use the method based on what is required in the calling logic. You are correct we are missing reset of local handle variables to null so there are leaks ongoing. Triggers and dialogs are not cleaned up at all in the commander. Alot of locations and groups were cleaned up a long time ago using a tool to detect the leaks automatically as it ran. That tool no longer works though.
24 player map still caton , even collapse
Well, I'm new here at AMAI. However, I think the script supports up to 12 players (at least that's what I could read in the code). @SMUnlimited can confirm this for you.
It works with 24 players, but it does put more stress on the system hence why memory leak fixes are more important.
It hasn't been unplayable for me though.
@SMUnlimited
I try to excretion some local variables , for reference only
but you must very look out
I change universal_peon_assignment , i want to at the beginning of the game, don't let all the peon go gold , have 1 go wood , 4 go gold , but on 24 player map , the game stuck , the game start is less than five minutes (I have compared the documents, and like change this code paragraph , the game can go on )
call HarvestGold(T,ver_optimal_gold - 1)
call HarvestWood(0,pwh)
call HarvestGold(T,1)
call HarvestWood(0,swh)
https://github.com/jzy-chitong56/amai-map/blob/main/common.eai
@SMUnlimited I rearrange excretion, but it still gets stuck , but maybe will Better
and the code include new towerrush,have new Variables, so you maybe just can comparison,
https://github.com/jzy-chitong56/amai-map/blob/main/common.ai
@SMUnlimited please try this Version https://github.com/jzy-chitong56/amai-map/tree/main/Scripts at the beginning of the game, Although when reporting no "27" appear , the game have some stuck (I still haven't found the rest of the excretion. Maybe I really forever can't found, but i will keep found ,I suspect The two neutral store check systems run at the same time. Because the unit group I use is the same global variable, when the two systems call at the same time, there will be a problem) buy game normal most of the time if you allow ,i will commit branch, after more testing (I use a lot of global variables, very rigid , consistent with AMAI philosophy)
Various of jzy-chitong56 optimizations merged into master