Jump to content
h4wek

Memory leak on spawn/despawn objects

Recommended Posts

I need to calculate cargo area for specified objects, so I make simple script for get real true info about that, but if you put this to console and wait few minutes (console run continuus this comand in loop and repeating this procedure many times by spawn/despawn all those objects) - the game is stack freezeeng or crash after close console - to repeat effect just put this to function file on empty VR map and you see effect.

 

//["B_Truck_01_cargo_F","Land_metalBarrel_F"] call boxcount  - command to put in console

 

boxcount = {

params ["_transportertype","_cargotype"]; private _boxcount = 0; private _cargos = []; private _full = false;

if (isClass (configfile >> "CfgVehicles" >> _transportertype >> "VehicleTransport" >> "Carrier")) then {
    _transporter = _transportertype createvehiclelocal [0,0,-1000];
    _cargo = _cargotype createvehiclelocal [0,0,-1100];

    while {!_full} do {
        if ((_transporter canVehicleCargo _cargo)#0) then {
            _transporter setVehicleCargo _cargo;
            _cargo = _cargotype createvehiclelocal [0,0,-1100];
            }else {_full = true};
    };

    _cargos = (getVehicleCargo _transporter);
    _boxcount = count _cargos;

    {deletevehicle _x}foreach _cargos;
    deletevehicle _transporter;
    deletevehicle _cargo;
};

_boxcount

};

 

after that nothing get game back to normal even FLUSH or SUPERFLUSH, only restart of mission clen memory area. Is any solution for that in engine? (this cause after longer perioid of time stack of dedicated server if game running very long on the same mission even optimalised scripts not help beacouse of this effect - it looks like every spawned object make space in memory and not relase it after delete completly - BI guys W..T...F? 

  • Like 1

Share this post


Link to post
Share on other sites
boxcount = 
{
    params ["_transportertype", "_cargotype"]; 

    private _boxcount = 0; 
    private _cargos = []; 
    private _full = false;

    if (isClass (configfile >> "CfgVehicles" >> _transportertype >> "VehicleTransport" >> "Carrier")) then 
    {
        _transporter = _transportertype createvehiclelocal [0, 0, -1000];
        _cargo = _cargotype createvehiclelocal [0, 0, -1100];

        while {!_full} do 
        {
            if ((_transporter canVehicleCargo _cargo)#0) then 
            {
                _success = _transporter setVehicleCargo _cargo;
                _cargo = _cargotype createvehiclelocal [0, 0, -1100];
            }
            else 
            {
            _full = true
            };
        };

        _cargos = (getVehicleCargo _transporter);
        _boxcount = count _cargos;

        {deletevehicle _x} foreach _cargos;
        deletevehicle _transporter;
        deletevehicle _cargo;
    };
    _boxcount
};

0 spawn
{
    startLoadingScreen ["Test"];
    for "_i" from 0 to 10000 do
    {
        private _result = ["B_Truck_01_cargo_F", "Land_metalBarrel_F"] call boxcount;
        //diag_log format ["%1: %2: %3", diag_tickTime, _result, _i];
        progressLoadingScreen (_i / 1000);
    };
    endLoadingScreen;
};

 

Cannot reproduce the performance degradation. Even after 50000 runs.

Share this post


Link to post
Share on other sites

Did you try to paste 

["B_Truck_01_cargo_F", "Land_metalBarrel_F"] call boxcount

in console view? and left console open (with paused game) for 5minutes? During this this time function will repeat to calculate result many more times than 50000;

like this:

?imw=5000&imh=5000&ima=fit&impolicy=Lett

Best to do this and watch effects open arma in window and (alt+ctr+del) task manager for look on system resourcesm graph of memory rise and rise up during opened console and paused game I get even 24GB of used memory on this (1 AI on empty VR map with 1 transport vehicle and barrels  in loop of create/delete)  - but bad effect starts even after few GB of rise up.

Share this post


Link to post
Share on other sites

I have proof of this issue on dedicated server during few hours of work when start to use C-Ram guns by AI,on every burst it spawn even 100 of drone_explosive detonations and those objects are deleted after that, dedicated have 50 FPS but scripts are so lagged that for ansver on action takes few seconds, so it is only question of growing empty reserved space after deleted objects in memory, and after this time all go to lagging like after this described method -> many spawned objects = memory overloaded by those spawned objects (even they are deleted already) -> lag is unstopable without restart of mission in this case.

So don't talk bull shits that everything is ok beacouse is not from probably begining of A3. Everyone can do this experiment and have prooof of bugged code of A3 on very deep level - just say  (nobody from those who can repair or understand this part of code not work in BI anymore instead - Cannot reproduce the performance degradation. Even after 50000 runs. )

Share this post


Link to post
Share on other sites

A while do loop should be smoothed by a sleep command. Without it, the loop runs too often (more than every frame, if I remember) for such aim.
If you intend to run it when game paused, change sleep command by uiSleep one.

while {uiSleep 0.2; !_full} do ....

Share this post


Link to post
Share on other sites

But there is not a problem of delay - in this way is no matter how offen do the code or how offen spawn objects - the main thing is: command make spawn and after that despawn /delete of this object and then make another repeat of this so if you break this loop sholdn't be more then one object spawned in memory (specially in pause mode) don't you think?

If I make operation:

spawn object (createvehicle _x) 

and then 

deletevehicle _x

and do this in serial loop miliard times what should be on miliard + 1 loop in memory ? (or something cause extended memory usage for every spawned object and this is not serial to this commands and when we use deletevehicle command not all of it is removed from memory before next iteration is started?)

why it make such strange behaviour on many repeats of this?

 

Share this post


Link to post
Share on other sites

I didn't dig in this script. Just dampening a hard while {true} loop or equivalent.

Not sure you can use vehicleCargo commands (so, with a consistent result about canVehicleCargo) with such vehicle cargo. On my mind, vehicle cargo are cars/APCs not all vehicles/objects from cfgVehicles. Not tested.

 

https://community.bistudio.com/wiki/Arma_3:_Vehicle_in_Vehicle_Transport

Share this post


Link to post
Share on other sites

with cargo vehicles turet/static guns are not allowed to load them to vehicles (by default in engine) - maybe you know why is that limit (is possibile to attachto those class objects - load vehicles is based on attachto command beacouse when you get attachedobjects from parent vehicle loaded vehicles are in that array) but not load to vehicle cargo by vehiclecargo function why (we not talk about obvious thing like size of object and if can fit inside etc it was checked already)??

 

BTW I made whole system to load unload vehicles/objects like this: 

 

so it is possibile but not with all kind of classes

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

×