Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13

Thread: [bug?] GetHeroLastSeenInfo() consuming too much memory

  1. #1
    Basic Member
    Join Date
    Dec 2016
    Posts
    46

    Question [bug?] GetHeroLastSeenInfo() consuming too much memory

    I have a function to consider glyph, but there is a function GetHeroLastSeenInfo() consuming too much memory. When I disable this function, the memory will no longer be so quickly exhausted
    Code:
    function ConsiderGlyph()
    	if GetGlyphCooldown() > 0  
    	then
    		return false
    	end
    	
        for i, BuildingID in pairs(Towers) do
            local tower = GetTower(GetTeam(), BuildingID)
    		if tower~=nil
    		then
    			local tableNearbyEnemyHeroes = utility.GetEnemiesNearLocation(tower:GetLocation(),700)
    			if tower:GetHealth() >=200 and tower:GetHealth() <=1000 and #tableNearbyEnemyHeroes>=2
    			then
    				GetBot():ActionImmediate_Glyph()
    				break
    			end
    		end
        end
    end
    Code:
    function GetEnemiesNearLocation(loc,dist)
    	if loc ==nil then
    		return {};
    	end
    	
    	local Enemies={};
    	
    	for _,enID in pairs(GetTeamPlayers(GetOtherTeam())) do
    		local enemyInfo=GetHeroLastSeenInfo(enID)[1];
    		if enemyInfo~=nil and enemyInfo['location']~=nil then
    			if IsHeroAlive(enID) and utility.GetDistance(enemyInfo['location'],loc)<=dist and (utility.GetDistance(enemyInfo['location'],Vector(0,0))>10) and enemyInfo['time_since_seen']<10 then
    				table.insert(Enemies,enID);
    			end
    		end
    	end
    	
    	return Enemies;
    end
    Log like this:
    Code:
    [VScript] LUA Memory usage warning: The VM has hit a new high usage of 542,113,792 bytes.
    [VScript] LUA Memory usage warning: The VM has hit a new high usage of 575,668,224 bytes.
    Script function 'AbilityLevelUpThink' on bot npc_dota_hero_phantom_assassin took 15.985ms
    [VScript] LUA Memory usage warning: The VM has hit a new high usage of 609,222,656 bytes.
    [VScript] LUA Memory usage warning: The VM has hit a new high usage of 642,777,088 bytes.
    [VScript] LUA Memory usage warning: The VM has hit a new high usage of 676,331,520 bytes.
    [VScript] LUA Memory usage warning: The VM has hit a new high usage of 709,885,952 bytes.
    Script function 'ItemPurchaseThink' on bot npc_dota_hero_night_stalker took 26.668ms
    [VScript] LUA Memory usage warning: The VM has hit a new high usage of 743,440,384 bytes.
    Script function 'CourierUsageThink' on bot npc_dota_hero_shadow_shaman took 63.448ms
    [VScript] LUA Memory usage warning: The VM has hit a new high usage of 776,994,816 bytes.

  2. #2
    Basic Member
    Join Date
    Mar 2012
    Posts
    2,018
    A few questions:
    1. What is Towers? And how is that table managed and added? (don't show only the adding code, but also, all the places where it gets called to be inserted). When is it called? How many times per frame? What are the conditions for the call?
    Code:
    for i, BuildingID in pairs(Towers) do
    2. in what file is ConsiderGlyph() located? When is it called? How many times per frame? What are the conditions for the call?
    3. What is GetOtherTeam() ? I assume it check if GetTam is blah blah return the opposite, but why not use GetOpposingTeam() ?


    I have a distinct feeling the Towers table is causing it but I am just guessing until I see how it's managed.
    Explanations on the normal, high and very high brackets in replays: here, here & here
    Why maphacks won't work in D2: here

  3. #3
    Basic Member
    Join Date
    Dec 2016
    Posts
    180
    Did you see this message rapidly in console??
    [ General ]: Script function hero selection took 2.181ms
    If yes, we both have same issue
    i am trying to find out what is the problem

  4. #4
    Quote Originally Posted by SIKIM View Post
    Did you see this message rapidly in console??
    [ General ]: Script function hero selection took 2.181ms
    If yes, we both have same issue
    i am trying to find out what is the problem
    I also have this problem. For me I thought it is related to my TeamThink, since I'm doing a lot of things there, but the weird thing is that it doesn't go away even when I increase the time per frame limit.

    @Adam: if this is true, that also answer my question about where is the memory leak, since I'm also using that function and get the memory usage warning. Probably chris is keeping all the hero information from the start of the match to handle GetHeroLastSeenInfo queries even though it is not necessary.

  5. #5
    Valve Developer
    Join Date
    Sep 2011
    Posts
    1,704
    It's possible I'm doing something dumb in the memory management of that function, I'll take a look.

  6. #6
    Basic Member
    Join Date
    Dec 2016
    Posts
    46
    Quote Originally Posted by ChrisC View Post
    It's possible I'm doing something dumb in the memory management of that function, I'll take a look.
    Thank you! And can you tell us some future plans on the bot script?

  7. #7
    Basic Member
    Join Date
    Dec 2016
    Posts
    180
    problem is not just in this function. I had same issue and hero_selection functions always trigger rapidly until the end of game

  8. #8
    Basic Member
    Join Date
    Mar 2012
    Posts
    2,018
    Are you sure SIKIM?

    hero_selection.Think() shoudl occur only during hero selection, hero_selection.UpdateLaneAssignments() is called only until 0:15 (so 15 seconds into the pre-game) which si why when you move around the map the bots change lanes, but stop and go to their lanes after 0:15 to meet the creeps at the half lane. And hero_selection.GetBotNames() is called once after the VM is initialized.

    That is how it should normally be.
    Explanations on the normal, high and very high brackets in replays: here, here & here
    Why maphacks won't work in D2: here

  9. #9
    Basic Member
    Join Date
    Dec 2016
    Posts
    180
    Yes, you are right. normally UpdateLane... is called only until 0:15 but here something goes wrong. I think hero_selection call repitition happens because of my bot_generic issue and some API functions that called many times in one frame( the matter is that I dont know which one ) . I will share some results related to this issue in the next hours.

    sometimes I rewrite the whole code and problem is solved( sometimes not ).

  10. #10
    Basic Member
    Join Date
    Dec 2016
    Posts
    180
    20170721212438_1.jpg this is image i want to share

    after many hours

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •