Jump to content

Recommended Posts

hello guys,
i made a script to spawn/de-spawn AI in a bubble around players, but on long run times (my aim is to make it run at least 24h) server crash with this error :
0xC0000005 - STATUS_ACCESS_VIOLATION
 after investigating, appears that is a generic error, there is no solution, and probably linked to memory leaks.
i tried 100% vanilla server and 100% vanilla client, and server crash in few hours.
considering that the server does not crash (24h+) if noone enters....and that the only script difference is that "AI bubble" around players does not spawn any units if there are no players, 
i take a wild guess and suppose its the "AI bubble" script causing this.  here is the script:

Spoiler

if (isServer) then {

/////////////////////////////////////////////////////////
DFN_dakka = {
   private _Dveh = _this select 0;
   while {faction (driver _Dveh) == "IND_F"} do {uiSleep 60;_Dveh setVehicleAmmo 1};
};
////////////////////////////////////////////////////////
D_FarFromAll = {
    uiSleep 1;
    params ["_pos", "_limit"]; // Read the parameters sent to the function into these variables.

    // First assume that the position is far from all players.
    private _farFromAll = true;

    // Loop through all players in a forEach loop.
    {
        // If the distance from the position to the player is less than the distance limit, then the position is not far from all
        if (_pos distance2D _x < _limit) then {
            _farFromAll = false;
        };
    } forEach playableUnits;          //  was: forEach call BIS_fnc_listPlayers;

    // Return the value in _farFromAll (do not write a semicolon after a return value)

   _pos = nil;
   _limit = nil;
   _farFromAll
};

/////////////////////////////////////////////////////////
DFN_Patrol = {
private _grp = _this select 0;
private _pos = _this select 1;
private _maxDist = _this select 2;
private _Dry = _this select 3;
private _Dspeed = _this select 4;
uiSleep 1;
_grp setBehaviour "AWARE";

//Create a string of randomly placed waypoints.
private ["_prevPos"];
_prevPos = _pos;
for "_i" from 0 to 3 do                 //was    for "_i" from 0 to (2 + (floor (random 3))) do
{
    private ["_wp", "_newPos"];
    _newPos = [_prevPos, 150, _maxDist, 0.5, _Dry, 0.3, 0] call BIS_fnc_findSafePos;          //D   2 = must be in water (0 = land)
    private _prevPos = _newPos;

    _wp = _grp addWaypoint [_newPos, 0];
    _wp setWaypointType "MOVE";
    _wp setWaypointCompletionRadius 200;

    //Set the group's speed and formation at the first waypoint.
    if (_i == 0) then
    {
        _wp setWaypointSpeed _Dspeed;      //or LIMITED  or FULL
        _wp setWaypointFormation "COLUMN";
    };
        _grp setBehaviour "SAFE";
};

//Cycle back to the first position.
private ["_wp"];
_wp = _grp addWaypoint [_pos, 0];
_wp setWaypointType "CYCLE";
_wp setWaypointCompletionRadius 200;

        _grp = nil;
        _pos = nil;
        _maxDist = nil;
        _Dry = nil;
        _Dspeed = nil;
        _i = nil;
        _newPos = nil;
    _prevPos = nil;
    _wp = nil;
true
};
/////////////////////////////////////////////////////////////

DFN_Dspawn = {
      uiSleep 1;
      private _maxDist = (_this select 0);
      private _minDist = (_this select 1);
      private _Dside = (_this select 2);
      private _DWPrange = (_this select 3);  // 3000
      private _Dtype = (_this select 4);
      private _DFNtype = (_this select 5);
      private _Dry = (_this select 6);       //0 = land only  1=waterORland 2=water only
      private _Dspeed = (_this select 7);
      waitUntil{sleep 3;(count playableUnits) > 0};

      private _allPPos = [];
      {_allPPos pushBack getpos _x} foreach playableUnits;  //was  allplayers
      private _RPPos = selectRandom _allPPos;
      private _Darea = [_RPPos, _minDist, _maxDist, 12, _Dry, 0.5, 0] call BIS_fnc_findSafePos;
      private _grpDveh = [_Darea,_Dside,_Dtype] call BIS_fnc_spawnGroup;                        // SPAWNER
      _grpDveh deleteGroupWhenEmpty true;
      [_grpDveh, _Darea, _DWPrange,_Dry,_Dspeed] call DFN_Patrol;                               // for patrol
      private _Dveh = vehicle leader _grpDveh;
      [_Dveh] spawn Drandomizer;                                                                // to randomize vehicles skin
      _Dveh setVariable ["NOT_remove",true,false];                                              // TO SAVE FROM CLEAN SCRIPT
      if (_Dveh isKindOf "I_G_offroad_01_armed_F") then {_Dveh setObjectTextureGlobal [0,'\A3\Soft_F_Bootcamp\Offroad_01\Data\offroad_01_ext_IG_04_CO.paa'];};  // to fix TFAR red pickup bug
      private _crewDveh = crew _Dveh;
      private _unitsDveh = units _grpDveh;
//      HINT "SPAWNED";  
      waitUntil { sleep 10; [(getPos _Dveh), _maxDist] call D_FarFromAll || !alive _Dveh };  // waituntil to allow side mission                          // variable to trigger side mission
      if !([(getPos _Dveh), _maxDist] call D_FarFromAll) then {
         if (_Dveh isKindOf "boat_F") then {sideSEA = true};                            // SIDE MISSION SEA
         if (_Dveh isKindOf "tank") then {sideTANK = true};                             // SIDE MISSION TANK

      };
      uiSleep 1;

      if (!alive _Dveh) then  {uiSleep 180};      
//      waitUntil { sleep 60; [(getPos _Dveh), 50] call D_FarFromAll};                  // to go on  
//      {deleteVehicle _x} forEach _crewDveh;
      {deleteVehicle _x} forEach (_unitsDveh + _crewDveh);
      deletevehicle _Dveh;
//      HINT "DELETED";
      uiSleep 1;      
      [_maxDist,_minDist,_Dside,_Dspeed] spawn _DFNtype;

      _maxDist = nil;
      _minDist = nil;
      _Dside = nil;
      _DWPrange = nil;
      _Dtype = nil;
      _DFNtype = nil;
      _Dry = nil;
      _Dspeed = nil;
      _allPPos = nil;
      _RPPos = nil;
      _Darea = nil;
      _grpDveh = nil;
      _Dveh = nil;
      _crewDveh = nil;
      _unitsDveh = nil;
};
///////////////////////////////////////////////////////////////////
Drandomizer = {
// send me an object and I will randomise its texture and global it
params ["_obj"];
private ["_textures","_mytexturelist","_texturesources"];
switch (true) do
    {
        default// everything else, grab all the available texs and choose one at random
            {
                _mytexturelist = (getArray (configFile/"CfgVehicles"/typeOf _obj/"texturelist")) select {typeName _x isEqualTo "STRING"};// array also contains numbers, remove them
                _texturesources = [];
                if (not (_mytexturelist isEqualTo [])) then
                {
                    {
                        _texturesources pushback ((getArray (configFile/"CfgVehicles"/typeOf _obj/"texturesources"/_x/"textures")) select 0);
                    }foreach _mytexturelist;
                    if (not (isnil "_texturesources")) then
                        {
                            _obj setObjectTextureGlobal [0,selectRandom _texturesources];
                        };
                };
            };
    };
};
///////////////////////////////////////////////////////////////////
DFN_CARS = {
      private _Dtype = selectRandom ["C_Offroad_01_F", "C_Offroad_01_repair_F", "C_Quadbike_01_F", "C_Hatchback_01_F", "C_Hatchback_01_sport_F", "C_SUV_01_F", "C_Van_01_transport_F", "C_Van_01_box_F", "C_Van_01_fuel_F"];
      private _maxDist = (_this select 0);
      private _minDist = (_this select 1);
      private _Dside = (_this select 2);
      private _DWPrange = 6000;
      [_maxDist,_minDist,_Dside,_DWPrange,[_Dtype],DFN_CARS,0,"FULL"] spawn DFN_Dspawn;

      _maxDist = nil;
      _minDist = nil;
      _Dside = nil;
      _DWPrange = nil;
      _Dtype = nil;    
   };
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
DFN_BOAT = {
      private _Dtype = selectRandom ["I_boat_armed_01_minigun_F"];     // DEFINE VEHICLES TYPE (SUBMARINE IS "I_SDV_01_F")
      private _maxDist = (_this select 0);
      private _minDist = (_this select 1);
      private _Dside = (_this select 2);
      private _DWPrange = 6000;
      [_maxDist,_minDist,_Dside,_DWPrange,[_Dtype],DFN_BOAT,2,"FULL"] spawn DFN_Dspawn;

      _maxDist = nil;
      _minDist = nil;
      _Dside = nil;
      _DWPrange = nil;
      _Dtype = nil;
   };
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
DFN_DIVER = {
      private _Dtype = ["I_diver_F","I_diver_F"];     // DEFINE VEHICLES TYPE (SUBMARINE IS "I_SDV_01_F")
      private _maxDist = (_this select 0);
      private _minDist = (_this select 1);
      private _Dside = (_this select 2);
      private _DWPrange = 900;
      [_maxDist,_minDist,_Dside,_DWPrange,_Dtype,DFN_DIVER,2,"FULL"] spawn DFN_Dspawn;

      _maxDist = nil;
      _minDist = nil;
      _Dside = nil;
      _DWPrange = nil;
      _Dtype = nil;
   };
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
DFN_CIV = {
      private _Dtype = selectRandom ["C_man_1", "C_man_1_1_F", "C_man_1_2_F", "C_man_1_3_F", "C_man_polo_1_F","C_man_polo_2_F", "C_man_polo_3_F", "C_man_polo_4_F", "C_man_polo_5_F", "C_man_polo_6_F", "C_man_p_fugitive_F", "C_man_p_beggar_F", "C_man_w_worker_F", "C_scientist_F", "C_man_hunter_1_F", "C_man_p_shorts_1_F", "C_journalist_F", "C_Orestes", "C_Nikos", "C_Nikos_aged"];
      private _maxDist = (_this select 0);
      private _minDist = (_this select 1);
      private _Dside = (_this select 2);
      private _DWPrange = 900;
      [_maxDist,_minDist,_Dside,_DWPrange,[_Dtype],DFN_CIV,0,"LIMITED"] spawn DFN_Dspawn;

      _maxDist = nil;
      _minDist = nil;
      _Dside = nil;
      _DWPrange = nil;
      _Dtype = nil;
   };
////////////////////////////////////////////////////////////////////////////////////////////////////////////////

DFN_Ginf = {
 
   _dice = selectRandom [0,1];
   if (_dice > 0) then {
      private _Dtype = selectRandom ["O_G_Soldier_LAT_F","I_ghillie_sard_F","I_soldier_AA_F" ];
      private _maxDist = (_this select 0);
      private _minDist = (_this select 1);
      private _Dside = (_this select 2);
      private _DWPrange = 900;
      [_maxDist,_minDist,_Dside,_DWPrange,[_Dtype],DFN_Ginf,0,"FULL"] spawn DFN_Dspawn;

      _maxDist = nil;
      _minDist = nil;
      _Dside = nil;
      _DWPrange = nil;
      _Dtype = nil;
   } else {
      private _Gs1 = selectRandom ["O_G_Soldier_LAT_F","I_ghillie_sard_F","I_soldier_AA_F" ];
      private _Gs2 = selectRandom ["O_G_Soldier_LAT_F","I_ghillie_sard_F","I_soldier_AA_F" ];
      private _Dtype = [_Gs1,_Gs2] ;   
      private _maxDist = (_this select 0);
      private _minDist = (_this select 1);
      private _Dside = (_this select 2);
      private _DWPrange = 900;
      [_maxDist,_minDist,_Dside,_DWPrange,_Dtype,DFN_Ginf,0,"FULL"] spawn DFN_Dspawn;

      _maxDist = nil;
      _minDist = nil;
      _Dside = nil;
      _DWPrange = nil;
      _Dtype = nil;
   };
};


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
DFN_Gveh = {
      private _Dtype = selectRandom ["I_APC_wheeled_03_cannon_F","I_G_offroad_01_armed_F", "I_MRAP_03_hmg_F","I_G_offroad_01_armed_F", "I_G_offroad_01_armed_F","I_APC_tracked_03_cannon_F","I_G_offroad_01_armed_F","I_MBT_03_cannon_F" ];
      private _maxDist = (_this select 0);
      private _minDist = (_this select 1);
      private _Dside = (_this select 2);
      private _DWPrange = 6000;
      [_maxDist,_minDist,_Dside,_DWPrange,[_Dtype],DFN_Gveh,0,"FULL"] spawn DFN_Dspawn;

      _maxDist = nil;
      _minDist = nil;
      _Dside = nil;
      _DWPrange = nil;
      _Dtype = nil;
   };
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
DFN_MINE = {
      private _maxDist = (_this select 0);
      private _minDist = (_this select 1);
      private _Dside = (_this select 2);
      private _Dtype = selectRandom ["ModuleMine_ATMine_F","ModuleMine_APERSBoundingMine_F"];
      private _allPPos = [];
      waitUntil{sleep 10;(count playableUnits) > 0};
      {_allPPos pushBack getpos _x} foreach playableUnits;
      private _RPPos = selectRandom _allPPos;
      private _Darea = [_RPPos, _minDist, _maxDist, 2, 1, 0.5, 0] call BIS_fnc_findSafePos;        // 0 = land only  1=waterORland 2=water only
      private _Dveh = _Dtype createVehicle _Darea;  
//      HINT "SPAWNED";
      private _DvehA = [_Dveh];
      waitUntil { sleep 15; [(getPos _Dveh), _maxDist] call D_FarFromAll };
      deletevehicle _Dveh;
//      HINT "DELETED";
      uiSleep 30;      
      [_maxDist,_minDist,_Dside] spawn DFN_MINE;

      _maxDist = nil;
      _minDist = nil;
      _Dside = nil;
      _DWPrange = nil;
      _Dtype = nil;
      _allPPos = nil;
      _RPPos = nil;
      _Darea = nil;
      _Dveh = nil;
      _DvehA = nil;
   };

};


in init.sqf:
call compile preprocessFileLineNumbers "DDscripts\Dbubble.sqf";
null = [] execVM "DDscripts\DambientSPAWN.sqf";
and here is the DambientSPAWN.sqf:
 

Spoiler

if (isServer) then {

 DScount = {
      uiSleep 0.8;
      private _SmaxDist = (_this select 0);   // 3000
      private _SminDist = (_this select 1);   // 2000
      private _DSside = (_this select 2);     // INDEPENDENT
      private _DStype = (_this select 3);     // DFN_BOAT
//      private _Dnum =  (_this select 4);      // number or units to spawn
//      private _i = _Dnum;
//      while {_i > 0} do {uiSleep 1;_i = _i - 1;null = [_SmaxDist,_SminDist,_DSside] spawn _DStype;};
      null = [_SmaxDist,_SminDist,_DSside] spawn _DStype;
      uiSleep 1;

      _SmaxDist = nil;
      _SminDist = nil;
      _DSside = nil;
      _DStype = nil;
//      _Dnum = nil;
//      _i = nil;
};

//[4000,3000,INDEPENDENT,DFN_BOAT] spawn DScount;
//Uisleep 1;
[4000,3000,INDEPENDENT,DFN_BOAT] spawn DScount;
Uisleep 1;
[500,400,INDEPENDENT,DFN_DIVER] spawn DScount;
Uisleep 1;

[450,400,INDEPENDENT,DFN_Ginf] spawn DScount;
Uisleep 1;
//[450,400,INDEPENDENT,DFN_Ginf] spawn DScount;
//Uisleep 1;
[900,800,INDEPENDENT,DFN_Ginf] spawn DScount;
Uisleep 1;
[900,800,INDEPENDENT,DFN_Ginf] spawn DScount;
Uisleep 1;
[1500,900,INDEPENDENT,DFN_Ginf] spawn DScount;
Uisleep 1;
//[1500,900,INDEPENDENT,DFN_Ginf] spawn DScount;
//Uisleep 1;

[2000,1500,INDEPENDENT,DFN_Gveh] spawn DScount;
Uisleep 1;
[2000,1500,INDEPENDENT,DFN_Gveh] spawn DScount;
Uisleep 1;
[3000,2500,INDEPENDENT,DFN_Gveh] spawn DScount;
Uisleep 1;
//[3000,2500,INDEPENDENT,DFN_Gveh] spawn DScount;
//Uisleep 1;
[4000,3000,INDEPENDENT,DFN_Gveh] spawn DScount;
Uisleep 1;
//[4000,3000,INDEPENDENT,DFN_Gveh] spawn DScount;
//Uisleep 1;

[300,120,INDEPENDENT,DFN_MINE] spawn DScount;
Uisleep 1;
[300,120,INDEPENDENT,DFN_MINE] spawn DScount;
Uisleep 1;

[2000,400,CIVILIAN,DFN_CARS] spawn DScount;
Uisleep 1;
[2000,400,CIVILIAN,DFN_CARS] spawn DScount;
Uisleep 1;
[2000,400,CIVILIAN,DFN_CARS] spawn DScount;
Uisleep 1;
[2000,400,CIVILIAN,DFN_CARS] spawn DScount;
Uisleep 1;
[2000,400,CIVILIAN,DFN_CARS] spawn DScount;
Uisleep 1;
[2000,700,CIVILIAN,DFN_CARS] spawn DScount;
Uisleep 1;
[4000,2000,CIVILIAN,DFN_CARS] spawn DScount;
Uisleep 1;
[4000,2000,CIVILIAN,DFN_CARS] spawn DScount;
Uisleep 1;

[600,100,CIVILIAN,DFN_CIV] spawn DScount;
[600,100,CIVILIAN,DFN_CIV] spawn DScount;
[600,100,CIVILIAN,DFN_CIV] spawn DScount;
[600,100,CIVILIAN,DFN_CIV] spawn DScount;
uiSleep 1;
[900,300,CIVILIAN,DFN_CIV] spawn DScount;
[900,300,CIVILIAN,DFN_CIV] spawn DScount;
[900,600,CIVILIAN,DFN_CIV] spawn DScount;
[900,600,CIVILIAN,DFN_CIV] spawn DScount;
uiSleep 1;

};

this actually works perfectly for few hours (from 1h to 4h usually), then the crash...

So i'm doing something "wrong"...and i mean unefficient or causing leaks ? the goal (if possible) it to leave no trace in the memory or in the game itself of the units created and then deleted,
or at least minimize the impact on the system to make it run as long as possible.
really thansk for any help!

Share this post


Link to post
Share on other sites

Are you running dedicated? 64 bit?

Does the crash happen with a vanilla map and units without any scripts running?

 

There's too much stuff happening, multiple calls and spawns so it's hard to tell from a quick glance.

Just from a general standpoint:
If you need to access data multiple times during mission runtime, save it to an array instead of constantly calling getArray/getText/getNumber from the config.

This way you have all the data you need already available upon mission start and can be sure that this won't increase memory usage of the game any further. Not to mention the performance increase:

 

selectrandom ("getNumber (_x >> 'scope') >= 2" configClasses (configFile >> "CfgVehicles"));//6.28931ms

//save to array in init.sqf or wherever you seem fit:
GOM_test = "getNumber (_x >> 'scope') >= 2" configClasses (configFile >> "CfgVehicles");

//access array:
selectrandom GOM_test;//0.0004ms

 

Other than that, have a read and try adding -malloc=system to start parameters.

Haven't been running one of my AI stuffed missions for longer periods lately, but once I switched over to 64bit dedi server executable, which you might recall, heh, I never experienced any crashes, even when running dedi and client on the same rig.

 

Any other info that might be useful?

 

Cheers

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

hello Grumpy!
thanks for your help ! :)

well, its dedicated (i have 2 servers, 1 on my home PC, the same as client with win7, and the other is a pure dedicated win10 machine) and always 64 bit (should i try 32 bit?)

awesome idea with config, will follow your example to adapt my script ! (by the way...its a new 1.82 bug that random vehicle skins are no longer random?)

about memory, my line actually is (dont know if its correct):
arma3server_x64 -port=2302 "-config=C:\STEAM\steamapps\common\Arma 3 Server\TADST\DWARtest\TADST_config.cfg" "-cfg=C:\STEAM\steamapps\common\Arma 3 Server\TADST\DWARtest\TADST_basic.cfg" "-profiles=C:\STEAM\steamapps\common\Arma 3 Server\TADST\DWARtest" -name=DWARtest -filePatching "-mod=curator;heli;jets;kart;mark;orange;tacops;tank" -autoInit -malloc=system

about the old memory problem that you can recall, this time the symptoms are a bit different (but maybe its related anyway), because server runs perfectly at 48 fps until sudden crash. there is no increasing memory usage, or server slowing.
the crash happens suddenly, at random time but with no sign that can happen soon.

other useful info...dont know...i post .rpt of vanilla server and client:
https://pastebin.com/GFJg1DGu
https://pastebin.com/JbKSVmxh
really thanks for your help!

Share this post


Link to post
Share on other sites

well...testing everything one by one, i found that without the spawn/despawn script, server runs for 24h ....so the problem must be there...to be specific in function :  DFN_Dspawn
as far as i know, "deleteGroupWhenEmpty" and "deleteVehicle" should have cleaned the old AI units, but apparently something is keeped somehow, for example i discovered that "alldead" is keeping count of every dead unit since start, even if deleted.
any idea how fix this ?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×