The particles that never died

by | Oct 28, 2026 | Unreal Engine

Part one of two on a week of Niagara particle performance work. Part two is about the things that were never broken in the first place.

A few weeks ago someone on the team mentioned that The Drifting Crown gets slower the longer you play. Not a crash, not a hitch. Just a run that starts at a comfortable 70 fps and ends somewhere around “why is the mouse lagging”. That kind of report is annoying, because there’s nothing to attach a breakpoint to. It’s also the kind that gets ignored for months if you let it.

We spent a week on it. This post is the first half: one bug, and the slightly embarrassing route we took to it.

Measuring before guessing

Our first suspect was the pickups’ recheck timer. That’s the code working out whether the player is standing on an energy orb. It had a timer, timers are suspicious, case closed.

Wrong. The timer costs about 0.024 ms when it runs at all. In this test it never ran once, because the player was standing still in an empty corner.

So we stopped guessing and built something to measure with. Three console commands, test builds only. One fills the run grid with cards. One spawns a batch of pickups. The third writes a row to a CSV file every five seconds, with the game thread time, GPU time, actor count and memory. On top of that sits a small script that drives the editor: open the map editor, wait, place a card, close it, spawn ten orbs, repeat. Then go and have lunch while it runs.

Why a CSV file rather than recording an Unreal Insights trace the whole time? Boring, practical reasons. A full trace writes about 5 MB a second. A two-hour run would have been 30 GB. So the CSV runs continuously, and we take ten-second trace snapshots at a few interesting points.

That setup is the reason the rest of this post exists, and most of part two as well. Every number in both came out of the same test.

99 ms a frame

First run: 30 cycles of open the map editor, place a card, close it, spawn pickups. Frame time went from 13 ms at the start to 99 ms at cycle 30. Ten fps, which matches the complaint exactly.

Two things stood out in the CSV, before we even opened a trace.

The growth was about 2.5 ms per cycle, and completely flat in between. Within a two-minute editor phase the frame time didn’t move at all. So it wasn’t piling up with playing time. It stepped at the cycles.

The second was where the time went. Our game thread was busy, but mostly busy waiting. It sat in Niagara‘s post-tick, which is where the game thread waits for the particle simulation jobs to finish. That wait had grown from 2.9 ms to 71 ms a frame. It waits for the whole batch, so the slowest job sets the price. We only had to find the slowest one.

It was the perk glow on the player’s weapon. Two copies of it, the whole time, costing 74 ms a frame by the end. Everything else in the frame stayed under about 25 ms.

One checkbox

Both of the glow’s emitters had Kill Particles When Lifetime Has Elapsed switched off. Each particle has a lifetime of well under a second. That lifetime was simply being ignored, because nothing ever killed anything.

The rest follows. An emitter spawns at 120-150 particles a second for four seconds. So every activation of the glow added about 1,100 particles per weapon. Those then simulated on the CPU for the rest of the level, with skeletal mesh sampling and location events attached. Something re-triggered the glow on each map editor cycle, so the batches stacked up.

Nothing was leaking, in the memory sense. The particles were all properly accounted for. They just never left.

Turning the kill back on fixed it, with one adjustment. The emitter’s loop behaviour was set to Once. With the kill on and the loop set to Once, the glow would vanish about five seconds after it started, which is not what a permanent perk should look like. So the loop went to Infinite as well.

The effect looks a little different now. Instead of the first four seconds of sparks hanging around forever, falling away under gravity, you get a steady stream of them. Honestly it looks better.

Same test again: 26 ms at cycle 30 instead of 99. The glow itself went from 74 ms to 0.1.

BeforeAfter
Start13.1 ms12.4 ms
Cycle 1042.4 ms17.2 ms
Cycle 2072.9 ms20.1 ms
Cycle 3099.4 ms (10 fps)26.2 ms (38 fps)

Then we checked the other 203

Finding a bug like that in one effect raises an obvious question about the other two hundred. So we audited every Niagara system in the project. There are 204 of them, and we looked for the two ways an effect can pile up.

The two ways

Immortal particles, which is what we’d just found. An emitter with its particle lifetime handling switched off, or with Kill Particles When Lifetime Has Elapsed unticked.

Systems that never finish, and that nobody cleans up. This one is sneakier. An effect spawned from a Blueprint normally destroys itself once it’s done. But an emitter set to loop forever is never done, and neither is one full of immortal particles. The self-destruct never fires. Spawn one of those, forget about it, and it stays until the level unloads.

As a component sitting on an actor, looping forever is fine. The same goes for an effect on a timed animation notify, which switches it off at the end. It’s the fire-and-forget spawn calls that bite.

Checking that by hand 204 times was not going to happen. So it ran as a script over our editor tooling. For each system it pulled the summary, the emitter list and the settings we cared about, then found every asset referencing it. After that it searched those Blueprints for spawn calls, and read the graphs of the ones that actually spawned something. Animation montages needed a separate pass through their notifies.

The one real leak

The audit found a single genuine problem, in the Roboto boss fight.

The boss’s lightning attack spawns a discharge effect at the end of every strike, and keeps no reference to it. One of that effect’s emitters loops forever, 25 particles every two seconds. So each lightning attack left one more running system hanging five metres above the boss. They stayed for the rest of the level, through the fight and every retry.

A sibling effect, the charge-up, was stored and destroyed properly. But only on the path where the attack finishes normally. Cancel the ability, kill the boss mid-attack, or hit Try again, and it stayed.

The fix is the dull kind. The ability gets a fresh set of variables on each attack, so it can simply hang on to the discharge effect when it spawns. Then, whenever the ability ends, it destroys the charge effect and switches the discharge one off. Destroying the charge effect also stops the charging sound attached to it, which was a small bonus. The discharge gets a fade rather than a hard cut, because the ability ends half a second after a 1.67-second finishing montage, while the effect is still on screen.

Everything else

The rest came back clean, or clean enough. The boss death montage leaves a few systems attached to a corpse, but that corpse gets destroyed anyway. A charged-shot orb grows while you hold the button, then dies when you let go. The fish school has its kill switched off on purpose, because the fish are meant to stay.

The genuinely broken ones were all in content the game doesn’t use: a toxic smoke system in a test level, some demo assets, an animation montage with _OLD in the name.

Notes to self

A checkbox can cost 74 ms a frame. There was no bad architecture here, and nothing to refactor. Someone unticked a box in a Niagara emitter, probably while making the sparks look right. The cost turned up two hundred metres away, as a stall on the game thread.

“It gets slower over time” usually means “it gets slower per something”. The useful part of that first CSV wasn’t the 99 ms. It was the flat line between the cycles. Flat, then a step, means you’re counting events rather than seconds. That ruled out half the suspects before we opened a trace.

When you find one instance of a mistake, go looking for the rest. The audit took an afternoon, and turned up a leak in a boss fight nobody had complained about yet.

Part two is the other half of the week. A stress test with 441 tiles on the board, and four things that worked exactly as designed while costing us a fortune.

The Drifting Crown is in development at Sponge Hammer.

Related posts

Nothing was broken, everything was just on

Nothing was broken, everything was just on

Part two of two. Part one was about a weapon glow whose particles never died. This one is about Unreal Engine culling, and four things that cost us frames while working exactly as designed. With the runaway bug gone, the frame time stopped climbing. It was still...