• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Group still leak after DestroyGroup

Level 5
Joined
May 10, 2024
Messages
57
Hi. I'm trying to understand why my ram usage and size of save file are increasing so quickly. I found a couple of threads about memory leaks and did a few tests based on that information.

I created an empty map with 100 units and 1 trigger which runs every 0.00 seconds. As soon as the map starts, I save the game and check memory usage. After 5 minutes I save the game again and compare the size of the save file and memory usage. When size of the file is bigger it always means that engine consumes more memory in game.

Test 1.
  • Tick
    • Events
      • Time - Every 0.00 seconds of game time
    • Conditions
    • Actions
0:00 sec | 1_00.00.w3z | 644KB
5:00 sec | 1_05.00.w3z | 644KB

The file size is same as before. Expected result. Continue.

Test 2.
  • Tick
    • Events
      • Time - Every 0.00 seconds of game time
    • Conditions
    • Actions
      • Set VariableSet group = (Units in (Playable map area))
0:00 sec | 2_00.00.w3z | 644KB
5:00 sec | 2_05.00.w3z | 1669KB

The file size has increased. It is a leak. Expected result. Continue.

Test 3.
  • Tick
    • Events
      • Time - Every 0.00 seconds of game time
    • Conditions
    • Actions
      • Set VariableSet group = (Units in (Playable map area))
      • Custom script: call DestroyGroup(udg_group)
0:00 sec | 3_00.00.w3z | 644KB
5:00 sec | 3_05.00.w3z | 739KB

The file size has increased but not as much as before. Unexpected result. Why does the file size keep increasing?
 

Attachments

  • LeakTest.w3m
    20 KB · Views: 2

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,287
Code:
function GetUnitsInRectMatching takes rect r, boolexpr filter returns group
    local group g = CreateGroup() // this variable is not null at time of function return, leaking a reference to the group preventing its id from being recycled.
    call GroupEnumUnitsInRect(g, r, filter)
    call DestroyBoolExpr(filter)
    return g
endfunction

//===========================================================================
function GetUnitsInRectAll takes rect r returns group
    return GetUnitsInRectMatching(r, null)
endfunction
Likely because of the local declared local handle variable reference leak on return bug.
 
Top