• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/
  • Weve updated the Tripwire Privacy Notice under our Policies to be clearer about our use of customer information to come in line with the EU General Data Protection Regulation (GDPR) rules that come into force today (25th May 2018). The following are highlights of our changes:


    We've incorporated the relevant concepts from the GDPR including joining the EU and Swiss Privacy Shield framework. We've added explanations for why and how Tripwire processes customer data and the types of data that we process, as well as information about your data protection rights.



    For more information about our privacy practices, please review the new Privacy Policy found here: https://tripwireinteractive.com/#/privacy-notice

Game desperately needs memory optimizations

simplecat

Active member
Apr 27, 2015
860
129
43
Russian Federation
docs.google.com
Correct me if i'm wrong, but here's the deal.

My FPS gradually decreases even though the scene intensity (players, particles, ZEDs etc...) remain at about same level. Usually i start the game with 100+ and end up having 50-40 on average.

Just had a ~2 hours endless online game with ~20 players on it. So i opened console to see how many actors (physical objects placed on map such as players, ZEDs, volumes, projectiles and pretty much everything that makes your game) are loaded in my memory. The result was ~5700. So i restarted the game and reconnected to server and on the fresh connection it showed me only 2500.

That's 3200 dynamic actors (e.g. non world related such as walls, blocking volumes, spawn points etc...) that my game will never ever use again but which still persist in the memory.

I have pretty average PC and medium settings, usually my game starts with 4.5gb RAM worth data and it feels smooth and fine but it later gets like twice bigger and stuttering begins. I've noticed that after beta 1 update it takes too long just to boot out of the game after playing for a hour or two, today i had to kill KF2 with task manager for the first time ever because game refused to flush data on its own. I'm talking about "big" endless servers with 32 players. In regular survival mode i suffer no issues but in endless its gets worse progressively.

I had no chance to scroll through the list of actors, as displayall command provides limited output but i've noticed that at least two there have a lot of instances - the one being KFPerkFXEmitterPool, the other isn't an actor but rather abstract object that still present in the memory - GameExplosion (had 32000 instances of these, with each storing its location, damage, radius etc).
 
Last edited:

Pharrahnox

FNG / Fresh Meat
Feb 3, 2016
268
71
0
Cranny mate
This probably belongs in the Bug Report section once more details are known.

It looks like there should be a single instance of KFPerkFXEmitterPool for each player on the server, as it is only spawned once in KFPawn_Human.PreBeginPlay. Interestingly, it is only used for airborne agent's explosion... Do you happen to know the damage or radius values for the explosions? This could be used to determine which type of explosion isn't being cleared from memory.

Since the output of getall/displayall is limited, next time could you refine your search to narrow in on the problem classes? E.g. getall GameExplosionActor InstigatorController, or getall GameExplosion Damage, getall GameExplosion DamageRadius, etc.

How did you get displayall to work on multiplayer? I can't use it except on singleplayer, but it would be really useful. Or did you mean getall?
 
  • Like
Reactions: simplecat

simplecat

Active member
Apr 27, 2015
860
129
43
Russian Federation
docs.google.com
Pharrahnox, thanks for your post!

Getall i meant, yeah.

I've been thinking about posting it in a bug report section but i feel like this is more of a global optimization issue and i'd love to see what people think about it (maybe even out of context of examples posted above, just some general thoughts). Maybe even get me a TWI employe response (yeah, i'm naive :D).

It does not seem like there even have to be a lvl 25 Medic using Airborne Agent. Game spawns new instances of this class on its own. Seems like this is relevance issue. As soon as you leave and enter other player's relevance area (e.g. for a period of time it stops existing on your machince) game assigns it a new instance. It fact as it closes replication channel it as well destroys a pawn instance too and spawns new one once get back. Hence plenty of PreBeginPlay events hapenning every now and then. I'm refering to this manual https://api.unrealengine.com/udk/Thr...html#Relevancy

I just joined 6p server as a spectator. At first there was 6 of KFPerkFXEmitterPool s, one for each pawn. Then it turned to 9, 15 and so on ending with 62 before i left.

Every GameExplosionActor gets flushed just fine, i have very few of them loaded at any given time but their templates (GameExplosion classes) are always in memory, shouldn't they disapper too? It affects all GameExplosion classes - grenades, husk projectiles, ground fire etc...
 
Last edited:
  • Like
Reactions: Pharrahnox

Pharrahnox

FNG / Fresh Meat
Feb 3, 2016
268
71
0
Cranny mate
(EDIT: I don't know why the top 2 quotes are broken.)
simplecat;n2325060 said:
Maybe even get me a TWI employe response (yeah, i'm naive :D).[\QUOTE]
Very naive indeed.

simplecat;n2325060 said:
It does not seem like there even have to be a lvl 25 Medic using Airborne Agent. Game spawns new instances of this class on its own.[\QUOTE]
Which class exactly? KFExplosion_AirborneAgent?

simplecat;n2325060 said:
Seems like this is relevance issue. As soon as you leave and enter other player's relevance area (e.g. for a period of time it stops existing on your machince) game assigns it a new instance. It fact as it closes replication channel it as well destroys a pawn instance too and spawns new one once get back. Hence plenty of PreBeginPlay events hapenning every now and then. I'm refering to this manual https://api.unrealengine.com/udk/Thr...html#Relevancy
I don't believe that the KFPawn_Human pawn of other players is spawned each time it becomes relevant to the local player. Also I don't see that stated in the relevancy section of the site you linked.
From my understanding (which is no means guaranteed to be correct, but I've done a substantial amount of netcode in Unrealscript in the past few years), relevance applies to property replication and whether actors should be spawned on the client when the actor is spawned on the server. It does not cause actors to pop in and out of existence on the client as it becomes relevant or irrelevant, respectively. That is, it does not cause the destruction and respawning of actors on the client. I don't know for sure whether the actor channel is closed and reopened as an actor changes relevance, but I doubt it. There would likely be significant overheads (both locally and through message passing) in doing this.

simplecat;n2325060 said:
I just joined 6p server as a spectator. At first there was 6 of KFPerkFXEmitterPool s, one for each pawn. Then it turned to 9, 15 and so on ending with 62 before i left.
Were many players dying? The KFPawn_Human instances are destroyed when a player dies, and a new one is created when a player (re)spawns. Perhaps the emitter pool is not being destroyed properly when the human pawn is destroyed.

simplecat;n2325060 said:
Every GameExplosionActor gets flushed just fine, i have very few of them loaded at any given time but their templates (GameExplosion classes) are always in memory, shouldn't they disapper too? It affects all GameExplosion classes - grenades, husk projectiles, ground fire etc...
This is quite interesting. There is very dangerous situation that can happen if an Object contains Actor references that aren't explicitly cleared when the references to the Object are removed. This prevents the garbage collector from cleaning them up. In the case of the GameExplosion for the airborne agent skill, this could prevent the emitter pool from being destroyed since there are still references to it. I haven't checked whether there are any Actor references in the GameExplosion Object, but it's a possible cause if there are.
 
Last edited:
  • Like
Reactions: simplecat

simplecat

Active member
Apr 27, 2015
860
129
43
Russian Federation
docs.google.com
Sorry for more weird talking. Whoever reads this probably thinking "what a nerd", but hey i'm a cool guy and all the girls around want to hang with me (*lies*)

Which class exactly? KFExplosion_AirborneAgent?
a new KFPerkFXEmitterPool, i mean it is initialized regardless, at this point (in PreBeginPlay) game doesn't care of perks and classes yet, just loads what it said to


No players were dying.


To be more accurate i was refering to this quote, my bad pointing to the wrong paragraph, this one from below
Spoiler!


What makes me think that constant cycle of spawning and destroying actors on client is an issue is the fact that when you get off their relevance area and come back, the player's pawn class instance changes.

Say you just joined the game and all your teammates are next to you, relevant. Their pawn classes have names kfpawn_human_0, 1... kfpawn_human_4...

But when you get away and come back their names change and now they are kf_pawn_human_5, 6... 8 and so on.


Not just airborne agent. Every template ever used by explosion actor that is a long time goner stays loaded.
 
Last edited:
  • Like
Reactions: Pharrahnox

Pharrahnox

FNG / Fresh Meat
Feb 3, 2016
268
71
0
Cranny mate
simplecat;n2325069 said:
What makes me think that constant cycle of spawning and destroying actors on client is an issue is the fact that when you get off their relevance area and come back, the player's pawn class instance changes.

Say you just joined the game and all your teammates are next to you, relevant. Their pawn classes have names kfpawn_human_0, 1... kfpawn_human_4...

But when you get away and come back their names change and now they are kf_pawn_human_5, 6... 8 and so on.

Not just airborne agent. Every template ever used by explosion actor that is a long time goner stays loaded.
That is interesting and unexpected (to me). I'm not currently in a position to do any rigorous testing or investigation due to other commitments, but at a later date I might do just that.

I guess the first thing would be to add this in KFPawn_Human.Destroyed:
Code:
if(PerkFXEmitterPool != None)
{
    PerkFXEmitterPool.Destroy();
    PerkFXEmitterPool = None;
}
That should fix the KFPerkFXEmitterPool spam, but I'm surprised it's not freed automatically. Then it's a matter of figuring out why the explosion templates aren't cleared. There must be references to them somewhere, otherwise they would be garbage collected since they're Objects.
 
  • Like
Reactions: simplecat

infntnub

Grizzled Veteran
Sep 25, 2012
2,162
78
48
Pennsylvania
I vaguely recall some board members having this issue in EA - not sure if it was specific to hardware or what though.

My rig is very basic and with a somewhat dated gpu (gtx 950) and I have never experienced the issues described :s
 

simplecat

Active member
Apr 27, 2015
860
129
43
Russian Federation
docs.google.com
Just an observation: just had really long endless game on 32 man server (yeah, i know it is not officially supported). KF2 ended up with 12gb ram used (normally for me it is 4-6). I had 39000 game explosion templates and 4300 instances of KFPerkFXEmitterPool.
 

Foster Parent

Tripwire Interactive Staff
Yes, non-supported modes are not a good way to report this kind of problem. There are reasons for the limits that exist. If you find things, I want to know, but it really helps if it is a thing we can make happen and observe in the vanilla game.

Also, simplecat what would the object count look like before and after the cyclic garbage collection routine? I know destroyed but uncleared objects, like full auto shell casings, can lead to memory problems, but have you watched the RAM graph in Task Manager rise over time, or are you just going by object count and if so, when do you count, relative to garbage collection?
 

simplecat

Active member
Apr 27, 2015
860
129
43
Russian Federation
docs.google.com
I haven't really watched over the memory graph with the exception of when i just to started play (~5 gb) and when i decided to stop (~11.5gb) but i assume it had been rising over the play course as my performance had slowly been getting worse.
With the exception of 4300 instances of KFPerkFXEmitterPool, actor count hasn't really changed, everything else just comes and goes away staying at the same level. But this and GameExplosion objects have never ever been cleared once and i ended having a lot of them. If i would quit the match and rejoined it again then it could have been reset and game could've start collecting them from the beginning.

Yep. 32 players server play worth a lot of data, but the problem (is it?) is there even on regular 6 players games. I think it is only a matter of how fast game accumulates redundand stuff.
 
Last edited:

simplecat

Active member
Apr 27, 2015
860
129
43
Russian Federation
docs.google.com
Just want to bump this thread. Game still keeps eating more RAM over the play course. Seems like more players there's on the server, the faster it happens. Screenshot was taking middle the match, 1h7m = +2.4gb ram used.

Spoiler!
 
Last edited:

GrooveSan

Member
Aug 30, 2015
34
4
8
Totally agree! It all started after the Revolt event has ended. And it's getting worse.
The game tends to start from mini-freezes to a totally unplayable 5 fps slide-show, after 2 or 3 map loadings.
Also, the game crashes much more than ever lately.

Inbefore:
YES, my pc is capable to run it smoothly on ultra;
NO, files verifying doesnt do any good;
YES, my internet connection is good;
YES, any other game works great on my pc.

Dear TWI, please do something about it.
 
  • Like
Reactions: simplecat

rolandq

FNG / Fresh Meat
May 6, 2019
2
0
0
30
The game just still keeps eating more RAM over the play course.
 
Last edited by a moderator:

GrooveSan

Member
Aug 30, 2015
34
4
8
Now I can 120% confirm there is something wrong going on because of the "Pawn_Human" thingy one guy mentioned before.
So, I've been playing the game on an empty server and everything was okay.
At the wave 2, the red text said that someone is connecting. After about 10 seconds (exactly as the person connected to the server), the game started to freezing and stuttering, although the new player didn't even spawned