How to actually delete a body from the memory?

This is not a question about the gameplay, but about the memory management mechanics.

The reason why I wonder is because I couldn’t find a way to do it clean. When there are too many bodies in the game, the game would crash - at least on PC, I haven’t met this on PS4.

On PC version of Hitman 2 (on Steam platform), I made very strict test with lots of patient. The level I chose is Miami. I just kept on pacifying NPCs and used different ways to deal with the bodies and see what would happen. And here are my test result:

Test 1: Leaving them on ground, hidden in safe corners. According to the increasing of bodies, I realized that the BGM is gone, and sometimes the sound of doors is gone, too. Then eventually the game would crash, and you can never successfully load the last save - it’ll crash.

Test 2: Trying to hide them in containers, such as chests, closets, etc. But the same thing happened. I though hiding in containers at least disabled the collisions, which reduces the physical updating pressure. But it seems like that the problem is the memory, not cpu, so, same thing happened.

Test 3: Dropping them into the ocean. The body would float on the surface of the ocean for a while then it’ll sink. So I think maybe when the body goes deep enough, the object management logic would delete them from memory - a good scene management strategy would do that, because technically an object in such a low altitude should never have any chance to come back to the scene and play its role. But, same problem happened. I wonder if it’s because of that the terrain near the seashore actually has a bottom, which means the altitude is actually limited, it’s just beyond the visible distance, and it’ definitely still inside the volume of the engine. Sometimes you can see that the body sinked and went through the seabed, and sometimes it’s lying on it. Which means sinking body still has collision, and the ocean has a bottom - some inside your view space, and some beyond it. The worst case is: all bodies that weren’t stopped by the seabed is sinking forever, which occupies both of your cpu and memory. Anyway, the ocean didn’t help.

Test 4: Shredder machine. I bet it’s the first idea came into your mind. But it’s the last case that I tested, because I thought it must work, so it should wait until I found out that no other way works. But the bad news is: it still doesn’t work. It took me a long time - longer than the ocean play - to shred so many bodies. But same problem happened. This totally confused me. Obviously, a shredder machine contains no bodies inside after we shred it. But why? Then I wonder if there would be a lazy programmer might thought: hey, who’s gonna check the inside of the shredder machine and we didn’t give the player any chance to do it, so why not just make the bottom deeper and just stack all bodies at the bottom? Or even easier - make no bottom for the machine, just let the body “sink to the ocean”.

Anyway, that’s all methods that I can think of. And it seems like that the game would never actually delete any npc from the scene.

Anyone has any opinions?


I think this is an issue with your simulation option lower it if you frequently kill everyone or get a stronger cpu

I have been thinking about this myself and everytime I’m doing kill everybody run I keep thinking about it.
My game won’t crash of “heaviness of dead bodies”, but still I always think about what happens with the bodies that are hidden or vanished. Your tests makes me think that game never forgets them and always consider them as a part of gameplay. And I will wonder why?
I mean the body that is hidden or shredded or have fallen from the tallest building in the world should just disappear and stop being counted as a part of gameplay. At least it would’ve been logical.
And that is weird that it’s not the case for the game.

As for the way to fix the crashes, my guess 3 pieces of hardware affect the performance.
They are: CPU, GPU and RAM.
Maybe CPU and GPU in pair, maybe all three in complex.
I can’t tell with confidence as I haven’t any chance to test.
I can assume the more memory you have, the more stable game will be.
As you haven’t provided your PC specs, I can’t tell what piece of hardware you would need to renew.
But for the first I would recommend to increase RAM capacity and see if this will fix the issue.
If not, I’m almost confident that GPU memory is responsible here.
So get a new GPU and you should be okay even without any need of replacing CPU.
Because GPU is responsible for graphics.
And it’s aproppriate to mention here the acticle I stumbled across few days ago.
The arcticle purpose was to determine what configuration will affect better games performance.
While testing various configurations they came to conclusion that it’s not actually important what CPU do you have as long as you have powerful modern GPU.
But relatively new CPU in complex with good GPU wlll work faster and more stable.

The moral of this tale is that you need hardware refreshments :slight_smile:

PC Hardware info:
CPU: Intel i5-9600KF 3.7G
RAM: 8GB x2 3200MHz

I don’t think it’s because of the RAM or CPU. Yes they have something to do with the capacity of bodies but I think it’s the responsibility of the scene management algorithm to delete unnecessary objects from the scene. No matter what, an abandoned dead body shouldn’t cost more runtime resources than a walking AI.

I wonder if there’s any way that I can communicate with the studio. If they can fix it, it’ll be a really good thing for the game.