• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[+GUI Tool] LeakLess

Level 6
Joined
Apr 16, 2007
Messages
177
What is it?
This is a library that fixes Group/Force/Lightning/Location leaks!
The Key is that stuff will be put on a "remove-this list" once it has been used by a BJ/native in the map (all GUI functions not introduced by EGUI are such functions)...
That list will be cleared every n (default:20) seconds.


What is so special about this?


Your code will be slightly slower, but you will no longer need to care about leak removal!
In the beta, Location, Group, Force and Lightning leaks will be fixed every 20 seconds...
In the testmap, that will happen every 2 seconds so you can actually see it happen.

Requires?
JassPack NewGen

How to import?
Just import this code in a custom script section of your map.

How to use?
It does all by itself.
UNLESS you want to keep Locations / Groups!

"call MakeHandlePermanent( udg_VarName, true)"

The Code
This is just for looking at! If you want to import the code into your map, I suggest using the attached txt file!

JASS:
library LeakLess initializer INIT
globals
    private constant real CLEAN_INTERVAL = 20 // Decides how often leaks will be fixed.
    boolean FixLeaks = true // Whether locations and groups are created temporary or not.
    private constant trigger LeakFixTrigger = CreateTrigger()
    private constant hashtable SecureTable = InitHashtable()
    
    private constant integer ON_LIST = 0
    private constant integer SAFE = 1
endglobals

//! textmacro LeakFix_Cleaner takes TYPE, DESTROYER
globals
    private integer Index = -1
    private $TYPE$ array Data
    private boolean Initialized = false
endglobals

private function CleanHandles takes nothing returns nothing
    local $TYPE$ h
    loop
        exitwhen Index == -1
        set h = Data[ Index ]
        call SetHandle( h, ON_LIST, false )
        if not IsHandle( h, SAFE ) then
            call $DESTROYER$( h )
        endif
        set Index = Index - 1
    endloop
    set h = null
endfunction


private function Write takes $TYPE$ data returns nothing    
    if not Initialized then
        set Initialized = true
        call TriggerAddAction( LeakFixTrigger, function CleanHandles  )
    endif
    if not ( IsHandle( data, ON_LIST ) or IsHandle( data, SAFE ) ) then
        set Index = Index + 1
        set Data[ Index ] = data
        call SetHandle( data, ON_LIST, true )
    endif
endfunction
//! endtextmacro


private function IsHandle takes handle h, integer what returns boolean
    return LoadBoolean( SecureTable, GetHandleId( h ), what )
endfunction

private function SetHandle takes handle h, integer what, boolean is returns nothing
    call SaveBoolean( SecureTable, GetHandleId( h ), what, is )
endfunction

function MakeHandlePermanent takes handle h, boolean is returns nothing
    call SetHandle( h, SAFE, is )
endfunction

private function INIT takes nothing returns nothing
    call TriggerRegisterTimerEvent( LeakFixTrigger, CLEAN_INTERVAL, true )
endfunction

    //-------------------- location --------------------

  scope LocationLeakFix
    //! runtextmacro LeakFix_Cleaner( "location", "RemoveLocation" )
    // Please enter functions that create the type here.
  
    private function FixAddLightningLocLeaks takes string codeName, location where1, location where2 returns nothing
        call Write( where1 )
        call Write( where2 )
    endfunction
    hook AddLightningLoc FixAddLightningLocLeaks

    private function FixAddSpecialEffectLocLeaks takes string modelName, location where returns nothing
        call Write( where )
    endfunction
    hook AddSpecialEffectLoc FixAddSpecialEffectLocLeaks

    private function FixAddSpecialEffectLocBJLeaks takes location where, string modelName returns nothing
        call Write( where )
    endfunction
    hook AddSpecialEffectLocBJ FixAddSpecialEffectLocBJLeaks

    private function FixAddSpellEffectByIdLocLeaks takes integer abilityId, effecttype t, location where returns nothing
        call Write( where )
    endfunction
    hook AddSpellEffectByIdLoc FixAddSpellEffectByIdLocLeaks

    private function FixAddSpellEffectLocLeaks takes string abilityString, effecttype t, location where returns nothing
        call Write( where )
    endfunction
    hook AddSpellEffectLoc FixAddSpellEffectLocLeaks

    private function FixAngleBetweenPointsLeaks takes location locA, location locB returns nothing
        call Write( locA )
        call Write( locB )
    endfunction
    hook AngleBetweenPoints FixAngleBetweenPointsLeaks

    private function FixCompareLocationsBJLeaks takes location A, location B returns nothing
        call Write( A )
        call Write( B )
    endfunction
    hook CompareLocationsBJ FixCompareLocationsBJLeaks

    private function FixCreateCorpseLocBJLeaks takes integer unitid, player whichPlayer, location loc returns nothing
        call Write( loc )
    endfunction
    hook CreateCorpseLocBJ FixCreateCorpseLocBJLeaks

    private function FixCreateDeadDestructableLocBJLeaks takes integer objectid, location loc, real facing, real scale, integer variation returns nothing
        call Write( loc )
    endfunction
    hook CreateDeadDestructableLocBJ FixCreateDeadDestructableLocBJLeaks

    private function FixCreateDestructableLocLeaks takes integer objectid, location loc, real facing, real scale, integer variation returns nothing
        call Write( loc )
    endfunction
    hook CreateDestructableLoc FixCreateDestructableLocLeaks

    private function FixCreateFogModifierRadiusLocLeaks takes player forWhichPlayer, fogstate whichState, location center, real radius, boolean useSharedVision, boolean afterUnits returns nothing
        call Write( center )
    endfunction
    hook CreateFogModifierRadiusLoc FixCreateFogModifierRadiusLocLeaks

    private function FixCreateFogModifierRadiusLocBJLeaks takes boolean enabled, player whichPlayer, fogstate whichFogState, location center, real radius returns nothing
        call Write( center )
    endfunction
    hook CreateFogModifierRadiusLocBJ FixCreateFogModifierRadiusLocBJLeaks

    private function FixCreateFogModifierRadiusLocSimpleLeaks takes player whichPlayer, fogstate whichFogState, location center, real radius, boolean afterUnits returns nothing
        call Write( center )
    endfunction
    hook CreateFogModifierRadiusLocSimple FixCreateFogModifierRadiusLocSimpleLeaks

    private function FixCreateImageBJLeaks takes string file, real size, location where, real zOffset, integer imageType returns nothing
        call Write( where )
    endfunction
    hook CreateImageBJ FixCreateImageBJLeaks

    private function FixCreateItemLocLeaks takes integer itemId, location loc returns nothing
        call Write( loc )
    endfunction
    hook CreateItemLoc FixCreateItemLocLeaks

    private function FixCreateNUnitsAtLocLeaks takes integer count, integer unitId, player whichPlayer, location loc, real face returns nothing
        call Write( loc )
    endfunction
    hook CreateNUnitsAtLoc FixCreateNUnitsAtLocLeaks

    private function FixCreateNUnitsAtLocFacingLocBJLeaks takes integer count, integer unitId, player whichPlayer, location loc, location lookAt returns nothing
        call Write( loc )
        call Write( lookAt )
    endfunction
    hook CreateNUnitsAtLocFacingLocBJ FixCreateNUnitsAtLocFacingLocBJLeaks

    private function FixCreatePermanentCorpseLocBJLeaks takes integer style, integer unitid, player whichPlayer, location loc, real facing returns nothing
        call Write( loc )
    endfunction
    hook CreatePermanentCorpseLocBJ FixCreatePermanentCorpseLocBJLeaks

    private function FixCreateTextTagLocBJLeaks takes string s, location loc, real zOffset, real size, real red, real green, real blue, real transparency returns nothing
        call Write( loc )
    endfunction
    hook CreateTextTagLocBJ FixCreateTextTagLocBJLeaks

    private function FixCreateUbersplatBJLeaks takes location where, string name, real red, real green, real blue, real alpha, boolean forcePaused, boolean noBirthTime returns nothing
        call Write( where )
    endfunction
    hook CreateUbersplatBJ FixCreateUbersplatBJLeaks

    private function FixCreateUnitAtLocLeaks takes player id, integer unitid, location whichLocation, real face returns nothing
        call Write( whichLocation )
    endfunction
    hook CreateUnitAtLoc FixCreateUnitAtLocLeaks

    private function FixCreateUnitAtLocByNameLeaks takes player id, string unitname, location whichLocation, real face returns nothing
        call Write( whichLocation )
    endfunction
    hook CreateUnitAtLocByName FixCreateUnitAtLocByNameLeaks

    private function FixCreateUnitAtLocSaveLastLeaks takes player id, integer unitid, location loc, real face returns nothing
        call Write( loc )
    endfunction
    hook CreateUnitAtLocSaveLast FixCreateUnitAtLocSaveLastLeaks

    private function FixDefineStartLocationLocLeaks takes integer whichStartLoc, location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook DefineStartLocationLoc FixDefineStartLocationLocLeaks

    private function FixDistanceBetweenPointsLeaks takes location locA, location locB returns nothing
        call Write( locA )
        call Write( locB )
    endfunction
    hook DistanceBetweenPoints FixDistanceBetweenPointsLeaks

    private function FixEnumDestructablesInCircleBJLeaks takes real radius, location loc, code actionFunc returns nothing
        call Write( loc )
    endfunction
    hook EnumDestructablesInCircleBJ FixEnumDestructablesInCircleBJLeaks

    private function FixGetLocationXLeaks takes location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook GetLocationX FixGetLocationXLeaks

    private function FixGetLocationYLeaks takes location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook GetLocationY FixGetLocationYLeaks

    private function FixGetLocationZLeaks takes location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook GetLocationZ FixGetLocationZLeaks

    private function FixGetRectFromCircleBJLeaks takes location center, real radius returns nothing
        call Write( center )
    endfunction
    hook GetRectFromCircleBJ FixGetRectFromCircleBJLeaks

    private function FixGetTerrainCliffLevelBJLeaks takes location where returns nothing
        call Write( where )
    endfunction
    hook GetTerrainCliffLevelBJ FixGetTerrainCliffLevelBJLeaks

    private function FixGetTerrainTypeBJLeaks takes location where returns nothing
        call Write( where )
    endfunction
    hook GetTerrainTypeBJ FixGetTerrainTypeBJLeaks

    private function FixGetTerrainVarianceBJLeaks takes location where returns nothing
        call Write( where )
    endfunction
    hook GetTerrainVarianceBJ FixGetTerrainVarianceBJLeaks

    private function FixGetUnitsInRangeOfLocAllLeaks takes real radius, location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook GetUnitsInRangeOfLocAll FixGetUnitsInRangeOfLocAllLeaks

    private function FixGetUnitsInRangeOfLocMatchingLeaks takes real radius, location whichLocation, boolexpr filter returns nothing
        call Write( whichLocation )
    endfunction
    hook GetUnitsInRangeOfLocMatching FixGetUnitsInRangeOfLocMatchingLeaks

    private function FixGroupEnumUnitsInRangeOfLocLeaks takes group whichGroup, location whichLocation, real radius, boolexpr filter returns nothing
        call Write( whichLocation )
    endfunction
    hook GroupEnumUnitsInRangeOfLoc FixGroupEnumUnitsInRangeOfLocLeaks

    private function FixGroupEnumUnitsInRangeOfLocCountedLeaks takes group whichGroup, location whichLocation, real radius, boolexpr filter, integer countLimit returns nothing
        call Write( whichLocation )
    endfunction
    hook GroupEnumUnitsInRangeOfLocCounted FixGroupEnumUnitsInRangeOfLocCountedLeaks

    private function FixGroupPointOrderByIdLocLeaks takes group whichGroup, integer order, location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook GroupPointOrderByIdLoc FixGroupPointOrderByIdLocLeaks

    private function FixGroupPointOrderLocLeaks takes group whichGroup, string order, location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook GroupPointOrderLoc FixGroupPointOrderLocLeaks

    private function FixGroupPointOrderLocBJLeaks takes group whichGroup, string order, location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook GroupPointOrderLocBJ FixGroupPointOrderLocBJLeaks

    private function FixIsLocationFoggedToPlayerLeaks takes location whichLocation, player whichPlayer returns nothing
        call Write( whichLocation )
    endfunction
    hook IsLocationFoggedToPlayer FixIsLocationFoggedToPlayerLeaks

    private function FixIsLocationInRegionLeaks takes region whichRegion, location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook IsLocationInRegion FixIsLocationInRegionLeaks

    private function FixIsLocationMaskedToPlayerLeaks takes location whichLocation, player whichPlayer returns nothing
        call Write( whichLocation )
    endfunction
    hook IsLocationMaskedToPlayer FixIsLocationMaskedToPlayerLeaks

    private function FixIsLocationVisibleToPlayerLeaks takes location whichLocation, player whichPlayer returns nothing
        call Write( whichLocation )
    endfunction
    hook IsLocationVisibleToPlayer FixIsLocationVisibleToPlayerLeaks

    private function FixIsPointBlightedBJLeaks takes location where returns nothing
        call Write( where )
    endfunction
    hook IsPointBlightedBJ FixIsPointBlightedBJLeaks

    private function FixIssueBuildOrderByIdLocBJLeaks takes unit whichPeon, integer unitId, location loc returns nothing
        call Write( loc )
    endfunction
    hook IssueBuildOrderByIdLocBJ FixIssueBuildOrderByIdLocBJLeaks

    private function FixIssueHauntOrderAtLocBJLeaks takes unit whichPeon, location loc returns nothing
        call Write( loc )
    endfunction
    hook IssueHauntOrderAtLocBJ FixIssueHauntOrderAtLocBJLeaks

    private function FixIssuePointOrderByIdLocLeaks takes unit whichUnit, integer order, location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook IssuePointOrderByIdLoc FixIssuePointOrderByIdLocLeaks

    private function FixIssuePointOrderLocLeaks takes unit whichUnit, string order, location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook IssuePointOrderLoc FixIssuePointOrderLocLeaks

    private function FixIssuePointOrderLocBJLeaks takes unit whichUnit, string order, location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook IssuePointOrderLocBJ FixIssuePointOrderLocBJLeaks

    private function FixIsTerrainPathableBJLeaks takes location where, pathingtype t returns nothing
        call Write( where )
    endfunction
    hook IsTerrainPathableBJ FixIsTerrainPathableBJLeaks

    private function FixIsUnitInRangeLocLeaks takes unit whichUnit, location whichLocation, real distance returns nothing
        call Write( whichLocation )
    endfunction
    hook IsUnitInRangeLoc FixIsUnitInRangeLocLeaks

    private function FixMeleeFindNearestMineLeaks takes location src, real range returns nothing
        call Write( src )
    endfunction
    hook MeleeFindNearestMine FixMeleeFindNearestMineLeaks

    private function FixMeleeGetLocWithinRectLeaks takes location src, rect r returns nothing
        call Write( src )
    endfunction
    hook MeleeGetLocWithinRect FixMeleeGetLocWithinRectLeaks

    private function FixMeleeGetProjectedLocLeaks takes location src, location targ, real distance, real deltaAngle returns nothing
        call Write( src )
        call Write( targ )
    endfunction
    hook MeleeGetProjectedLoc FixMeleeGetProjectedLocLeaks

    private function FixMeleeRandomHeroLocLeaks takes player p, integer id1, integer id2, integer id3, integer id4, location loc returns nothing
        call Write( loc )
    endfunction
    hook MeleeRandomHeroLoc FixMeleeRandomHeroLocLeaks

    private function FixMeleeStartingUnitsForPlayerLeaks takes race whichRace, player whichPlayer, location loc, boolean doHeroes returns nothing
        call Write( loc )
    endfunction
    hook MeleeStartingUnitsForPlayer FixMeleeStartingUnitsForPlayerLeaks

    private function FixMeleeStartingUnitsHumanLeaks takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing
        call Write( startLoc )
    endfunction
    hook MeleeStartingUnitsHuman FixMeleeStartingUnitsHumanLeaks

    private function FixMeleeStartingUnitsNightElfLeaks takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing
        call Write( startLoc )
    endfunction
    hook MeleeStartingUnitsNightElf FixMeleeStartingUnitsNightElfLeaks

    private function FixMeleeStartingUnitsOrcLeaks takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing
        call Write( startLoc )
    endfunction
    hook MeleeStartingUnitsOrc FixMeleeStartingUnitsOrcLeaks

    private function FixMeleeStartingUnitsUndeadLeaks takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing
        call Write( startLoc )
    endfunction
    hook MeleeStartingUnitsUndead FixMeleeStartingUnitsUndeadLeaks

    private function FixMeleeStartingUnitsUnknownRaceLeaks takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing
        call Write( startLoc )
    endfunction
    hook MeleeStartingUnitsUnknownRace FixMeleeStartingUnitsUnknownRaceLeaks

    private function FixMoveLightningLocLeaks takes lightning whichBolt, location where1, location where2 returns nothing
        call Write( where1 )
        call Write( where2 )
    endfunction
    hook MoveLightningLoc FixMoveLightningLocLeaks

    private function FixMoveLocationLeaks takes location whichLocation, real newX, real newY returns nothing
        call Write( whichLocation )
    endfunction
    hook MoveLocation FixMoveLocationLeaks

    private function FixMoveRectToLocLeaks takes rect whichRect, location newCenterLoc returns nothing
        call Write( newCenterLoc )
    endfunction
    hook MoveRectToLoc FixMoveRectToLocLeaks

    private function FixOffsetLocationLeaks takes location loc, real dx, real dy returns nothing
        call Write( loc )
    endfunction
    hook OffsetLocation FixOffsetLocationLeaks

    private function FixPanCameraToLocForPlayerLeaks takes player whichPlayer, location loc returns nothing
        call Write( loc )
    endfunction
    hook PanCameraToLocForPlayer FixPanCameraToLocForPlayerLeaks

    private function FixPanCameraToTimedLocForPlayerLeaks takes player whichPlayer, location loc, real duration returns nothing
        call Write( loc )
    endfunction
    hook PanCameraToTimedLocForPlayer FixPanCameraToTimedLocForPlayerLeaks

    private function FixPanCameraToTimedLocWithZForPlayerLeaks takes player whichPlayer, location loc, real zOffset, real duration returns nothing
        call Write( loc )
    endfunction
    hook PanCameraToTimedLocWithZForPlayer FixPanCameraToTimedLocWithZForPlayerLeaks

    private function FixPingMinimapLocForForceLeaks takes force whichForce, location loc, real duration returns nothing
        call Write( loc )
    endfunction
    hook PingMinimapLocForForce FixPingMinimapLocForForceLeaks

    private function FixPingMinimapLocForForceExLeaks takes force whichForce, location loc, real duration, integer style, real red, real green, real blue returns nothing
        call Write( loc )
    endfunction
    hook PingMinimapLocForForceEx FixPingMinimapLocForForceExLeaks

    private function FixPingMinimapLocForPlayerLeaks takes player whichPlayer, location loc, real duration returns nothing
        call Write( loc )
    endfunction
    hook PingMinimapLocForPlayer FixPingMinimapLocForPlayerLeaks

    private function FixPlaySoundAtPointBJLeaks takes sound soundHandle, real volumePercent, location loc, real z returns nothing
        call Write( loc )
    endfunction
    hook PlaySoundAtPointBJ FixPlaySoundAtPointBJLeaks

    private function FixPolarProjectionBJLeaks takes location source, real dist, real angle returns nothing
        call Write( source )
    endfunction
    hook PolarProjectionBJ FixPolarProjectionBJLeaks

    private function FixRectContainsLocLeaks takes rect r, location loc returns nothing
        call Write( loc )
    endfunction
    hook RectContainsLoc FixRectContainsLocLeaks

    private function FixRectFromCenterSizeBJLeaks takes location center, real width, real height returns nothing
        call Write( center )
    endfunction
    hook RectFromCenterSizeBJ FixRectFromCenterSizeBJLeaks

    private function FixRectFromLocLeaks takes location min, location max returns nothing
        call Write( min )
        call Write( max )
    endfunction
    hook RectFromLoc FixRectFromLocLeaks

    private function FixRegionAddCellAtLocLeaks takes region whichRegion, location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook RegionAddCellAtLoc FixRegionAddCellAtLocLeaks

    private function FixRegionClearCellAtLocLeaks takes region whichRegion, location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook RegionClearCellAtLoc FixRegionClearCellAtLocLeaks

    private function FixRestoreUnitLocFacingAngleBJLeaks takes string key, string missionKey, gamecache cache, player forWhichPlayer, location loc, real facing returns nothing
        call Write( loc )
    endfunction
    hook RestoreUnitLocFacingAngleBJ FixRestoreUnitLocFacingAngleBJLeaks

    private function FixRestoreUnitLocFacingPointBJLeaks takes string key, string missionKey, gamecache cache, player forWhichPlayer, location loc, location lookAt returns nothing
        call Write( loc )
        call Write( lookAt )
    endfunction
    hook RestoreUnitLocFacingPointBJ FixRestoreUnitLocFacingPointBJLeaks

    private function FixReviveHeroLocLeaks takes unit whichHero, location loc, boolean doEyecandy returns nothing
        call Write( loc )
    endfunction
    hook ReviveHeroLoc FixReviveHeroLocLeaks

    private function FixRotateCameraAroundLocBJLeaks takes real degrees, location loc, player whichPlayer, real duration returns nothing
        call Write( loc )
    endfunction
    hook RotateCameraAroundLocBJ FixRotateCameraAroundLocBJLeaks

    private function FixSetBlightLocLeaks takes player whichPlayer, location whichLocation, real radius, boolean addBlight returns nothing
        call Write( whichLocation )
    endfunction
    hook SetBlightLoc FixSetBlightLocLeaks

    private function FixSetBlightRadiusLocBJLeaks takes boolean addBlight, player whichPlayer, location loc, real radius returns nothing
        call Write( loc )
    endfunction
    hook SetBlightRadiusLocBJ FixSetBlightRadiusLocBJLeaks

    private function FixSetCameraPositionLocForPlayerLeaks takes player whichPlayer, location loc returns nothing
        call Write( loc )
    endfunction
    hook SetCameraPositionLocForPlayer FixSetCameraPositionLocForPlayerLeaks

    private function FixSetCameraQuickPositionLocLeaks takes location loc returns nothing
        call Write( loc )
    endfunction
    hook SetCameraQuickPositionLoc FixSetCameraQuickPositionLocLeaks

    private function FixSetCameraQuickPositionLocForPlayerLeaks takes player whichPlayer, location loc returns nothing
        call Write( loc )
    endfunction
    hook SetCameraQuickPositionLocForPlayer FixSetCameraQuickPositionLocForPlayerLeaks

    private function FixSetDoodadAnimationBJLeaks takes string animName, integer doodadID, real radius, location center returns nothing
        call Write( center )
    endfunction
    hook SetDoodadAnimationBJ FixSetDoodadAnimationBJLeaks

    private function FixSetFogStateRadiusLocLeaks takes player forWhichPlayer, fogstate whichState, location center, real radius, boolean useSharedVision returns nothing
        call Write( center )
    endfunction
    hook SetFogStateRadiusLoc FixSetFogStateRadiusLocLeaks

    private function FixSetImagePositionBJLeaks takes image whichImage, location where, real zOffset returns nothing
        call Write( where )
    endfunction
    hook SetImagePositionBJ FixSetImagePositionBJLeaks

    private function FixSetItemPositionLocLeaks takes item whichItem, location loc returns nothing
        call Write( loc )
    endfunction
    hook SetItemPositionLoc FixSetItemPositionLocLeaks

    private function FixSetRectFromLocLeaks takes rect whichRect, location min, location max returns nothing
        call Write( min )
        call Write( max )
    endfunction
    hook SetRectFromLoc FixSetRectFromLocLeaks

    private function FixSetSoundPositionLocBJLeaks takes sound soundHandle, location loc, real z returns nothing
        call Write( loc )
    endfunction
    hook SetSoundPositionLocBJ FixSetSoundPositionLocBJLeaks

    private function FixSetTerrainPathableBJLeaks takes location where, pathingtype t, boolean flag returns nothing
        call Write( where )
    endfunction
    hook SetTerrainPathableBJ FixSetTerrainPathableBJLeaks

    private function FixSetTerrainTypeBJLeaks takes location where, integer terrainType, integer variation, integer area, integer shape returns nothing
        call Write( where )
    endfunction
    hook SetTerrainTypeBJ FixSetTerrainTypeBJLeaks

    private function FixSetTextTagPosBJLeaks takes texttag tt, location loc, real zOffset returns nothing
        call Write( loc )
    endfunction
    hook SetTextTagPosBJ FixSetTextTagPosBJLeaks

    private function FixSetUnitFacingToFaceLocTimedLeaks takes unit whichUnit, location target, real duration returns nothing
        call Write( target )
    endfunction
    hook SetUnitFacingToFaceLocTimed FixSetUnitFacingToFaceLocTimedLeaks

    private function FixSetUnitPositionLocLeaks takes unit whichUnit, location whichLocation returns nothing
        call Write( whichLocation )
    endfunction
    hook SetUnitPositionLoc FixSetUnitPositionLocLeaks

    private function FixSetUnitPositionLocFacingBJLeaks takes unit whichUnit, location loc, real facing returns nothing
        call Write( loc )
    endfunction
    hook SetUnitPositionLocFacingBJ FixSetUnitPositionLocFacingBJLeaks

    private function FixSetUnitPositionLocFacingLocBJLeaks takes unit whichUnit, location loc, location lookAt returns nothing
        call Write( loc )
        call Write( lookAt )
    endfunction
    hook SetUnitPositionLocFacingLocBJ FixSetUnitPositionLocFacingLocBJLeaks

    private function FixSetUnitRallyPointLeaks takes unit whichUnit, location targPos returns nothing
        call Write( targPos )
    endfunction
    hook SetUnitRallyPoint FixSetUnitRallyPointLeaks

    private function FixSmartCameraPanBJLeaks takes player whichPlayer, location loc, real duration returns nothing
        call Write( loc )
    endfunction
    hook SmartCameraPanBJ FixSmartCameraPanBJLeaks

    private function FixTerrainDeformationCraterBJLeaks takes real duration, boolean permanent, location where, real radius, real depth returns nothing
        call Write( where )
    endfunction
    hook TerrainDeformationCraterBJ FixTerrainDeformationCraterBJLeaks

    private function FixTerrainDeformationRandomBJLeaks takes real duration, location where, real radius, real minDelta, real maxDelta, real updateInterval returns nothing
        call Write( where )
    endfunction
    hook TerrainDeformationRandomBJ FixTerrainDeformationRandomBJLeaks

    private function FixTerrainDeformationRippleBJLeaks takes real duration, boolean limitNeg, location where, real startRadius, real endRadius, real depth, real wavePeriod, real waveWidth returns nothing
        call Write( where )
    endfunction
    hook TerrainDeformationRippleBJ FixTerrainDeformationRippleBJLeaks

    private function FixTerrainDeformationWaveBJLeaks takes real duration, location source, location target, real radius, real depth, real trailDelay returns nothing
        call Write( source )
        call Write( target )
    endfunction
    hook TerrainDeformationWaveBJ FixTerrainDeformationWaveBJLeaks

    private function FixTransmissionFromUnitTypeWithNameBJLeaks takes force toForce, player fromPlayer, integer unitId, string unitName, location loc, sound soundHandle, string message, integer timeType, real timeVal, boolean wait returns nothing
        call Write( loc )
    endfunction
    hook TransmissionFromUnitTypeWithNameBJ FixTransmissionFromUnitTypeWithNameBJLeaks

    private function FixUnitDamagePointLocLeaks takes unit whichUnit, real delay, real radius, location loc, real amount, attacktype whichAttack, damagetype whichDamage returns nothing
        call Write( loc )
    endfunction
    hook UnitDamagePointLoc FixUnitDamagePointLocLeaks

    private function FixUnitDropItemPointLocLeaks takes unit whichUnit, item whichItem, location loc returns nothing
        call Write( loc )
    endfunction
    hook UnitDropItemPointLoc FixUnitDropItemPointLocLeaks

    private function FixUnitUseItemPointLocLeaks takes unit whichUnit, item whichItem, location loc returns nothing
        call Write( loc )
    endfunction
    hook UnitUseItemPointLoc FixUnitUseItemPointLocLeaks

    private function FixWaygateSetDestinationLocBJLeaks takes unit waygate, location loc returns nothing
        call Write( loc )
    endfunction
    hook WaygateSetDestinationLocBJ FixWaygateSetDestinationLocBJLeaks

  endscope
    


    //-------------------- group --------------------

  scope GroupLeakFix
    //! runtextmacro LeakFix_Cleaner( "group", "DestroyGroup" )
    // Please enter functions that create the type here.
  
    private function FixCountUnitsInGroupLeaks takes group g returns nothing
        call Write( g )
    endfunction
    hook CountUnitsInGroup FixCountUnitsInGroupLeaks

    private function FixFirstOfGroupLeaks takes group whichGroup returns nothing
        call Write( whichGroup )
    endfunction
    hook FirstOfGroup FixFirstOfGroupLeaks

    private function FixForGroupLeaks takes group whichGroup, code callback returns nothing
        call Write( whichGroup )
    endfunction
    hook ForGroup FixForGroupLeaks

    private function FixForGroupBJLeaks takes group whichGroup, code callback returns nothing
        call Write( whichGroup )
    endfunction
    hook ForGroupBJ FixForGroupBJLeaks

    private function FixGetRandomSubGroupLeaks takes integer count, group sourceGroup returns nothing
        call Write( sourceGroup )
    endfunction
    hook GetRandomSubGroup FixGetRandomSubGroupLeaks

    private function FixGroupAddGroupLeaks takes group sourceGroup, group destGroup returns nothing
        call Write( sourceGroup )
        call Write( destGroup )
    endfunction
    hook GroupAddGroup FixGroupAddGroupLeaks

    private function FixGroupAddUnitLeaks takes group whichGroup, unit whichUnit returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupAddUnit FixGroupAddUnitLeaks

    private function FixGroupAddUnitSimpleLeaks takes unit whichUnit, group whichGroup returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupAddUnitSimple FixGroupAddUnitSimpleLeaks

    private function FixGroupClearLeaks takes group whichGroup returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupClear FixGroupClearLeaks

    private function FixGroupEnumUnitsInRangeLeaks takes group whichGroup, real x, real y, real radius, boolexpr filter returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupEnumUnitsInRange FixGroupEnumUnitsInRangeLeaks

    private function FixGroupEnumUnitsInRangeCountedLeaks takes group whichGroup, real x, real y, real radius, boolexpr filter, integer countLimit returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupEnumUnitsInRangeCounted FixGroupEnumUnitsInRangeCountedLeaks

    private function FixGroupEnumUnitsInRangeOfLocLeaks takes group whichGroup, location whichLocation, real radius, boolexpr filter returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupEnumUnitsInRangeOfLoc FixGroupEnumUnitsInRangeOfLocLeaks

    private function FixGroupEnumUnitsInRangeOfLocCountedLeaks takes group whichGroup, location whichLocation, real radius, boolexpr filter, integer countLimit returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupEnumUnitsInRangeOfLocCounted FixGroupEnumUnitsInRangeOfLocCountedLeaks

    private function FixGroupEnumUnitsInRectLeaks takes group whichGroup, rect r, boolexpr filter returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupEnumUnitsInRect FixGroupEnumUnitsInRectLeaks

    private function FixGroupEnumUnitsInRectCountedLeaks takes group whichGroup, rect r, boolexpr filter, integer countLimit returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupEnumUnitsInRectCounted FixGroupEnumUnitsInRectCountedLeaks

    private function FixGroupEnumUnitsOfPlayerLeaks takes group whichGroup, player whichPlayer, boolexpr filter returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupEnumUnitsOfPlayer FixGroupEnumUnitsOfPlayerLeaks

    private function FixGroupEnumUnitsOfTypeLeaks takes group whichGroup, string unitname, boolexpr filter returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupEnumUnitsOfType FixGroupEnumUnitsOfTypeLeaks

    private function FixGroupEnumUnitsOfTypeCountedLeaks takes group whichGroup, string unitname, boolexpr filter, integer countLimit returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupEnumUnitsOfTypeCounted FixGroupEnumUnitsOfTypeCountedLeaks

    private function FixGroupEnumUnitsSelectedLeaks takes group whichGroup, player whichPlayer, boolexpr filter returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupEnumUnitsSelected FixGroupEnumUnitsSelectedLeaks

    private function FixGroupImmediateOrderLeaks takes group whichGroup, string order returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupImmediateOrder FixGroupImmediateOrderLeaks

    private function FixGroupImmediateOrderBJLeaks takes group whichGroup, string order returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupImmediateOrderBJ FixGroupImmediateOrderBJLeaks

    private function FixGroupImmediateOrderByIdLeaks takes group whichGroup, integer order returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupImmediateOrderById FixGroupImmediateOrderByIdLeaks

    private function FixGroupPickRandomUnitLeaks takes group whichGroup returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupPickRandomUnit FixGroupPickRandomUnitLeaks

    private function FixGroupPointOrderLeaks takes group whichGroup, string order, real x, real y returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupPointOrder FixGroupPointOrderLeaks

    private function FixGroupPointOrderByIdLeaks takes group whichGroup, integer order, real x, real y returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupPointOrderById FixGroupPointOrderByIdLeaks

    private function FixGroupPointOrderByIdLocLeaks takes group whichGroup, integer order, location whichLocation returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupPointOrderByIdLoc FixGroupPointOrderByIdLocLeaks

    private function FixGroupPointOrderLocLeaks takes group whichGroup, string order, location whichLocation returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupPointOrderLoc FixGroupPointOrderLocLeaks

    private function FixGroupPointOrderLocBJLeaks takes group whichGroup, string order, location whichLocation returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupPointOrderLocBJ FixGroupPointOrderLocBJLeaks

    private function FixGroupRemoveGroupLeaks takes group sourceGroup, group destGroup returns nothing
        call Write( sourceGroup )
        call Write( destGroup )
    endfunction
    hook GroupRemoveGroup FixGroupRemoveGroupLeaks

    private function FixGroupRemoveUnitLeaks takes group whichGroup, unit whichUnit returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupRemoveUnit FixGroupRemoveUnitLeaks

    private function FixGroupRemoveUnitSimpleLeaks takes unit whichUnit, group whichGroup returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupRemoveUnitSimple FixGroupRemoveUnitSimpleLeaks

    private function FixGroupTargetDestructableOrderLeaks takes group whichGroup, string order, widget targetWidget returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupTargetDestructableOrder FixGroupTargetDestructableOrderLeaks

    private function FixGroupTargetItemOrderLeaks takes group whichGroup, string order, widget targetWidget returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupTargetItemOrder FixGroupTargetItemOrderLeaks

    private function FixGroupTargetOrderLeaks takes group whichGroup, string order, widget targetWidget returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupTargetOrder FixGroupTargetOrderLeaks

    private function FixGroupTargetOrderBJLeaks takes group whichGroup, string order, widget targetWidget returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupTargetOrderBJ FixGroupTargetOrderBJLeaks

    private function FixGroupTargetOrderByIdLeaks takes group whichGroup, integer order, widget targetWidget returns nothing
        call Write( whichGroup )
    endfunction
    hook GroupTargetOrderById FixGroupTargetOrderByIdLeaks

    private function FixGroupTrainOrderByIdBJLeaks takes group g, integer unitId returns nothing
        call Write( g )
    endfunction
    hook GroupTrainOrderByIdBJ FixGroupTrainOrderByIdBJLeaks

    private function FixIsUnitGroupDeadBJLeaks takes group g returns nothing
        call Write( g )
    endfunction
    hook IsUnitGroupDeadBJ FixIsUnitGroupDeadBJLeaks

    private function FixIsUnitGroupEmptyBJLeaks takes group g returns nothing
        call Write( g )
    endfunction
    hook IsUnitGroupEmptyBJ FixIsUnitGroupEmptyBJLeaks

    private function FixIsUnitGroupInRectBJLeaks takes group g, rect r returns nothing
        call Write( g )
    endfunction
    hook IsUnitGroupInRectBJ FixIsUnitGroupInRectBJLeaks

    private function FixIsUnitInGroupLeaks takes unit whichUnit, group whichGroup returns nothing
        call Write( whichGroup )
    endfunction
    hook IsUnitInGroup FixIsUnitInGroupLeaks

    private function FixSelectGroupBJLeaks takes group g returns nothing
        call Write( g )
    endfunction
    hook SelectGroupBJ FixSelectGroupBJLeaks

    private function FixSelectGroupForPlayerBJLeaks takes group g, player whichPlayer returns nothing
        call Write( g )
    endfunction
    hook SelectGroupForPlayerBJ FixSelectGroupForPlayerBJLeaks

  endscope
    
  
endlibrary


Special Thanks
Vexorian... hook is awesome.
The SciTe developers & the ruby interpreter
The internet


Q&A
Q: Does this work with EGUI?
A: Well... Not all leaks might be removed...

Q: Cannot I just use EGUI?
A: EGUI does not automatically remove memory leaks.


Q: Does this make GUIers lazy?
A: No. It just makes them productive and more creative.

Q: Is this slow?
A: Well... It's slower than removing stuff manuable, but faster than not removing it at all.

Q: Does this leak?
A: You get leaks if you just create Locations without using them.

Q: How do I install this?
A: Press Alt-F4. That will automatically install all files needed. Alternatively, read the thread.
 

Attachments

  • LeakLessII.txt
    50.1 KB · Views: 143
  • LeakLess DEMO MAP.w3x
    65.5 KB · Views: 86
Last edited:
Level 6
Joined
Apr 16, 2007
Messages
177
Do you think so?
I have a couple of questions for you:
Have you installed EGUI?
Does EGUI automatically fix memory leaks (okay, you still need to import the JASS code into your maps for this to actually work)?

Also you can still use EGUI with this ( Install EGUI first, then run this script and put the JASS code into your map ).

thanks in advance, SerraAvenger
 
Level 6
Joined
Apr 16, 2007
Messages
177
Thanks for your reply!

1) This thing can bug if you get a buffer overflow
Last time I checked, everything can bug if you get a buffer overflow...
So please precise : )
What part will bug? The exe or my JASS code?
How exactly will it bug?
How can I fix it (given I can fix it)

2) CreateNUnitsAtLoc doesn't leak. Neither does CreateNUnitsAtLocFacingLocBJ I think.
Uh, it just assigns to a global group. You are absolutely right : )

3) Only groups and locations?
If anything else is needed, telll me and I will cnp the wrappers in my ruby code which will automatically generate the wrappers and the substitution code.

What's this for?
JASS:
Write...
    set Data[ PermIndex ] = data
    set data = Data[ LEAK_BUFFER ]
    return Data[ PermIndex ]

Destroying the reference for handle recycling. I think Vex wrote that you get a permanent pointer leak if you don't null arguments, and I don't want to add handle leaks that weren't there before. Not sure on this though, but unecessary safety > unecessary fail
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
Last time I checked, everything can bug if you get a buffer overflow...
So please precise : )
What part will bug? The exe or my JASS code?
How exactly will it bug?
How can I fix it (given I can fix it)
How can I know if your exe bugs without the sourcecode? While you're at it, maybe attach the ruby sourcecode too.

I'm ofcourse talking about the jass.
Let's say you create 40 locations, that means:
Data[0] to Data[39] is used.
Now if you create another location, you call the destructor of Data[0] and then set Data[0] = location41.
Which means that if you use more than 40 locations in 1 trigger (without waits), you destroy your first location(s) before being able to use them.

There's no fix for this, the only thing you could do is increase the buffer size to e.g. 255 or 8190. That'd reduce the chances of the bug occuring. Since jass arrays have a fixed size anyway, you might as well increase the buffer size.

Then again, I guess GUI users won't really be using more than 40 locations at the exact same time. So it's probably not a big deal, but it's still a potential bug.

If anything else is needed, telll me and I will cnp the wrappers in my ruby code which will automatically generate the wrappers and the substitution code.
There are other leaks too (which are frequently used): Player groups (forces), lightnings, special effects, just to name the most important ones.

Destroying the reference for handle recycling. I think Vex wrote that you get a permanent pointer leak if you don't null arguments, and I don't want to add handle leaks that weren't there before. Not sure on this though, but unecessary safety > unecessary fail
No, function arguments are about the only thing where the reference counter DOES decrease upon return, as far as I know. So arguments don't need to be nulled, only local variables. Which means you can safely remove set data = Data[ LEAK_BUFFER ] twice.

Also: what's NAME used for?
//! textmacro LeakBuffer takes NAME, TYPE, DESTROYER
 
Level 6
Joined
Apr 16, 2007
Messages
177
How can I know if your exe bugs without the sourcecode? While you're at it, maybe attach the ruby sourcecode too.

oops forgot I hadn't uploaded the sourcecode here, only at th >_>

So it's probably not a big deal, but it's still a potential bug.

Shall I add a point in the thread for changing the value?

Player groups (forces), lightnings, special effects

Will come after the next version

No, function arguments are about the only thing where the reference counter DOES decrease upon return, as far as I know. So arguments don't need to be nulled, only local variables. Which means you can safely remove set data = Data[ LEAK_BUFFER ] twice.

In Eleandor we trust.

Also: what's NAME used for?
//! textmacro LeakBuffer takes NAME, TYPE, DESTROYER

Forgot to remove it. Was used for some clever function naming.

Best wishes, Serra
 
Level 17
Joined
Mar 17, 2009
Messages
1,349
When the Points and Groups are removed, does this function exactly like the RemoveLocation and DestroyGroup scripts?
If so, then in my opinion it's better to do it manually for it would then be faster and have same efficiency. Also it's an easy task to accomplish.
If not, then how is it better? Other than relieving the user from this easy task?

Moreover, shouldn't we all remember that Forces and Rects also leak?
If I would want a GUI leak remover, I wouldn't want it to remove half the leaks but all of them... including Special Effects and all the values that use handles.

But I must say, impressive work and it can be actually very beneficial for amateur GUI'ers.

Keep it up!
 
Level 6
Joined
Apr 16, 2007
Messages
177
Well but you didn't the one important question I asked... is it exactly like using RemoveLocation script or DestroyGroup, better, or worse?

The code itself is a tiny bit slower than using RemoveLocation.
The development time, however, is shortened since you no longer need to do stuff like
  • Some Trigger
    • Set tmp_Loc = Position of Triggering Unit
    • -------- Do something with the location --------
    • Custom script: call RemoveLocation( udg_tmp_Loc )
Instead, just use your GUI code as if you didn't know about memory leaks.
 
Level 6
Joined
Apr 16, 2007
Messages
177
Now i get it! Wow this can be really helpful after second thought!!
Does this mean won't have to worry about MUI-ness (in some cases) since points (and all other leaks) aren't set into variables anymore? :)

Well...
I have to disappoint you, but that is not perfectly true.
Whenever you need to use a point after a wait, you need to make sure the point still exists after the wait.

For those cases, the executable adds a new function to the GUI of your world editor. With that function you can turn off the system.
This is necessary, as you never know how long your points/groups etc are there before they get removed by the System.

When you turn off the System...
It is just like before. You still need to use variables and RemoveLocation (etc).

Thus it doesn't add MUI - it only removes Leaks. Which is quite useful, though.
 
Level 6
Joined
Feb 26, 2008
Messages
171
Good tool! Some leaks don't have to be removed right after use. Some leaks are removed in another trigger for some cases. I won't use it but it's good :p

off-topic: would be good a tool that makes things MUI :D would be my DREAM!
 
Level 17
Joined
Mar 17, 2009
Messages
1,349
OK I've got a thought for MUI! It's just a brainstormed idea so might not work.

Remember how you told me that the purpose for it not to be MUI when using Wait is because you don't know exactly when the leak will be destroyed. Well scratch your head a bit and adjust it in a manner where you can set the time interval for it to be destroyed...

Would it work then? :)
 
Level 6
Joined
Apr 16, 2007
Messages
177
OK I've got a thought for MUI! It's just a brainstormed idea so might not work.

Remember how you told me that the purpose for it not to be MUI when using Wait is because you don't know exactly when the leak will be destroyed. Well scratch your head a bit and adjust it in a manner where you can set the time interval for it to be destroyed...

Would it work then? :)

I'm sorry to say, but a leak removal tools cannot be used to make things MUI.

I was, however, thinking about adding some sort of MUI functionality plugin which would allow to use TriggerExecCount without having to know about it.

Basically there would still be the two typical MUI problems:
- MUI timed actions (like for n seconds, deal d damage every second to unit u)
- MUI after waits (like wait n seconds, then destroy the last created effect)

Thus there would be needed 2 Main functions, one that adds a structure called 'Static Timers' and allows to attach indicies to started timers, might just as well simply use a GUI frontend for an extended version of Cohadars Timer Systems (never used it, dunno know the name)

And for the waits thingie we might use TriggerExecCount.
I just won't be able to program these, I'll just finish the engine in the next couple of weeks... Anyone who knows how the triggerdata / triggerstrings files take their parameters will then be able to create plugins for GUI++.

If anyone knows ruby, I'ld be quite glad if he could help with the application. Just e-mail me over sourceforge or send me an pm...

Thank you :)
 
Level 2
Joined
Jun 10, 2007
Messages
27
This is quite an amazing little tool you've got here! However, I'm experiencing a little bit of trouble actually running the GUI tool itself xD. Whenever I run the tool, I get this error (see attachments).

I'm running Vista x64, which I'm guessing is the cause of the problem.
 

Attachments

  • Untitled.png
    Untitled.png
    44.8 KB · Views: 107
Level 3
Joined
Jul 12, 2009
Messages
32
Does this delete stuff for all triggers??

So if i read correctly it just makes it so you can use one line instead of three for every time you do something that would normaly leak. Only thing is not very specific. =/ How long before it randomly deletes my point? Will it happen to all existing ones? Or just the ones in the trigger? A "short time" uhh.. doesn't tell me much. It's only good if it only deletes leaks or w/e in that trigger, because otherwise if you had a point in a different trigger still in used this would kill ALL the points and ruin everything.

so.. Delete all existing temporary whatchamagigs?
or.. Delete temporary crap on that trigger?

What if i DON"T wanna delete somthin'? Then i need to know if it effects all triggers.

W/e Still useful.
 
Last edited:
Level 6
Joined
Apr 16, 2007
Messages
177
BUMP - Major update. This now doesn't use ruby anymore, just cnp into your map...

So if i read correctly it just makes it so you can use one line instead of three for every time you do something that would normaly leak.

Locations and Groups just stopped leaking, so you don't need to use anything like DestroyGroup or RemoveLocation anymore


Only thing is not very specific. =/ How long before it randomly deletes my point?

Every 20 seconds (customisable though), everything will be cleaned.

A "short time" uhh.. doesn't tell me much.
The version before, time until removal depended on how fast you were creating new stuff (when you created the thinge number n+40, the nth would be removed; Eg location #41 -> loc #1 removed). The new version just removes everything every 20 seconds - unless you used "call FixLeaksSJ( false )" in a custom script line.

It's only good if it only deletes leaks or w/e in that trigger, [blablabla]

EDIT: Old idea trashed. Too anti-intuitive and anti-user friendly : )

In order to make stuff not be removed, use "call MakeHandlePermanent( udg_VarName, true )"
This should forever stop it from being removed...
 
Last edited:
Level 6
Joined
Apr 16, 2007
Messages
177

This fixes more stuff, has a human readable library, doesn't require other libraries, can easily be extended*, doesn't remove "permanent" handles that weren't permanent at the first use, doesn't do unnecessary counting, catches all usages of those handles, will not have to wait for a DoNothing to destroy eaks (I never used that in ANY my GUI maps when I was still using GUI!), still works if you spam DoNothing (not that anyone would use it anyway) etc etc.


*Just tell me a type that leaks and I've got it added in 1 minute. No joke.

EDIT: Basic concept is the same though. Funny how two people get the same idea independant of each other: D

EDIT2: Seems part of what I saw isn't true.
"doesn't remove "permanent" handles that weren't permanent at the first use, ", his doesn't either but uses a strange loop system to get that.
"will not have to wait for a DoNothing to destroy eaks (I never used that in ANY my GUI maps when I was still using GUI!),", his doesn't either. Just seems as if the DoNothing would also start a DestroyLeaks thingie... not 100% sure though. That code is really cluttered...
 
Level 11
Joined
Nov 4, 2007
Messages
337
Well, I really didn't see click on thbis thing before.
But I got intersted because of my auto Memory Leak destroyer and clicked on it;

Well,
you didn't seem to understand my system quietly.
Why didn't I hook all BJs?
Because I did it smarter and only hooked the functions that are necessary.

Actually the things you do are using the looks for moving units/gibing them orders/creating them.
So I do only have to hook these functions.
So that makes it smarter and more efficient.
In GUI GroupEnum goes always with a ForGroup call.
So it's much better to hook ForGroup than hooking all GroupEnums.

will not have to wait for a DoNothing to destroy eaks (I never used that in ANY my GUI maps when I was still using GUI!), still works if you spam DoNothing (not that anyone would use it anyway) etc etc.

Mine does also clear the stuff automatically.
And it does still work when you spam DoNothing.

This fixes more stuff

Unneccessary stuff. The other things do not cause such bad leaks and can be fixed more easy.

can easily be extended

Mine, too

doesn't remove "permanent" handles that weren't permanent at the first use

Mine doesn,t oo

Funny how two people get the same idea independant of each other: D

Yep, it is.
But I didn't steal your idea. Really. This is the first time I click on this thread.
I actually thought it was some kind of programm where you insert GUI code and it says 'The code is clean'.

his doesn't either but uses a strange loop system to get that.

You didn't understand that, right?
That's the comfort part:
Data are only removed when they've been in the system at least CLEAN_INTERVAL_SECONDS.
So every x secs. I pass the leaks to the destroyer. Then they're killed after x secs.
While the destroyer is running, no new handles are added and put to the passer first.
So you don't have to protect all the handles.


Also I don't see a part where your system actually destroys the leaks?
I don't think my code is cluttered.
Just read the comments.

Oh, and do you have a thing that checks if users remove the handles on their own?
You should add it, really.

unnecessary counting

The counting does only eat performance when you put the var to true that declares if the system shall count the KBs.
Also I do not think it's unneccessarry.
It can help you decide whether you want to use the system and helps you see it*'s importancy.



Aaand:
Mine doesn't break JASS.
 
Last edited:
Level 6
Joined
Apr 16, 2007
Messages
177
Well,
you didn't seem to understand my system quietly.
Why didn't I hook all BJs?
Because I did it smarter and only hooked the functions that are necessary.

I know. I just parsed the common.j and blizzard.j for functions that use the types I want to destroy, and hooked to them. Btw, the word you're looking for is "completely", not "quietly"


Mine does also clear the stuff automatically.
And it does still work when you spam DoNothing.
Yeah, I've seen it. Looked like it at first glance tho.



Unneccessary stuff. The other things do not cause such bad leaks and can be fixed more easy.

Maybe, maybe not.

Yep, it is.
But I didn't steal your idea. Really. This is the first time I click on this thread.
I actually thought it was some kind of programm where you insert GUI code and it says 'The code is clean'.

I never said so. I said "independent from each other". I had the idea to use hooks when I was in Ireland, which was around the time when you uploaded the system. When I came back, I wrote the idea into the TheHelper thread (9.4) and implemented it a week later. Before, I was using a rubyscript to modify WE triggerdata and make it use my functions instead of BJ functions.

That's the "comfort" part:
Data are only removed when they've been in the system at least CLEAN_INTERVAL_SECONDS.
So every x secs. I pass the leaks to the destroyer. Then they're killed after x secs.
While the destroyer is running, no new handles are added and put to the passer first.
So you don't have to protect all the handles.

I understood that, but I still think it's quite a strange looping system, moving the handles into another array.
You could as well have used a counter to see how long the stuff was actually in "destroy-phase".

Also I don't see a part where your system actually destroys the leaks?

Leaks are cleaned in the "CleanHandles" function.

I don't think my code is cluttered.
Just read the comments.

Ppl code different. To me, your code seems cluttered :p


Oh, and do you have a thing that checks if users remove the handles on their own?
You should add it, really.

That's a good idea. Will do at some time.



The counting does only eat performance when you put the var to true that declares if the system shall count the KBs.
Also I do not think it's unneccessarry.
It can help you decide whether you want to use the system and helps you see it*'s importancy.

Still I think its pointless. If you feel the urge to see by how much the system made your life easier, disable it and play the map once. Numbers don't really matter, it's the playing experience that does.


Aaand:
Mine doesn't break JASS.

Perhaps I should only parse the blizzard.j.
When I decided to parse both, it was for the reason I wasn't sure which natives were used by the GUI directly (some are, like Location(x,y)).

>>can easily be extended
>Mine, too
Your system is hand crafted. Mine is computer generated. I just give my ruby script the type I want to catch, the functions I want it to catch (I can do that easily using vexorians API) and it will write all of the hooks for me.
You will have to think which functions to hook and will have to write the hooks manually... That's not 'easily' ; )

anyhow thanks for your interest, Serra
 
Level 11
Joined
Nov 4, 2007
Messages
337
Ok, I agree with everything except these points:

Still I think its pointless. If you feel the urge to see by how much the system made your life easier, disable it and play the map once. Numbers don't really matter, it's the playing experience that does.

I still think it's useful. People have different computers.

I understood that, but I still think it's quite a strange looping system, moving the handles into another array.
You could as well have used a counter to see how long the stuff was actually in "destroy-phase".

Believe me, I thought clearly about how I was gonna do that.
But this is simply the most efficient and least complicated way.
A part of the reason is explained here:

JASS:
    // We want that the user doesn't have to protect too many variables, but all the variables that are filled longer
    // than CLEAN_UP_INTERVAL seconds. But what, when the handle thing is put into the destroy stack and the next destroy is
    // in 5 seconds, because the last one was 15 seconds ago? We can simply avoid something like that by using a 2-step-system
    // that goes sure, the handle is only destroyed when it passed the CLEAN_UP_INTERVAL twice.
    // Having two kinds of variables is simply easier and more efficient than having another variable that refers to
    // how many times the handle passed the timer; If it isn't passed/cleared in the Interval then, we can't loop
    // that easily through the data and we'd have to fix gaps later; That would suck a lot of performacne.

And I'll explain the rest:
If we just make a new variable that defines how many times the thing ran through the loop or something like that, we can't simply count the integer destroyCount down, we have to save the biggest place of the handle and check if the var is a gap or not.
Or we have to clean the gaps, and parse the variables together.
But that would simply be bad for the performance;
Also the time after which handles are destroyed stick closer to CLEAN_UP_INTERVAL this way.
 
Last edited:
Level 8
Joined
Oct 3, 2008
Messages
367
>Would it be better to just hook the Create functions, and destroy them with a timer.

Last I checked, hooks don't affect functions in blizzard.j. Of course, I could be wrong.

Does this serve a purpose now that Malte's version that does essentially the same thing is approved?
 
Top