Elektrine lite

← Feed

@NohatCoder@mastodon.gamedev.place

Post #957131

2026-04-04 22:40 UTC

Idea: Single use virtual memory. Don't bother ever reusing the same virtual memory space, you always allocate in a new place, and once you free it is gone. If you have a true 64 bit virtual memory space then this is surprisingly practical. There is no remotely realistic scenario where you are ever going to run out. Upsides include a dead simple allocator, and a guarantee that use-after-free will result in a hardware exception. What is not to like?

Replies (5)

  • @NohatCoder 1 byte allocation now wastes 4095 bytes + in-kernel metadata.

    Open ##1898350

  • @JennyFluff@chitter.xyz 2026-04-04 23:24

    @NohatCoder single use memory? techbros going too far this time

    Open ##1898356

  • @NohatCoder Fun bit of trivia: I did this on God of War (2017) because I couldn’t find which job was stomping over another’s stack. I allocated 1024 stacks and gave a new one to each job. It took a few frames before I exhausted them and had to reuse one. But the stacks had virtual addresses that were unmapped the moment a job was done — so if a stack pointer was used after a job, it crashed! Which it never did — turns out, I wasn’t chasing a memory stomp. But that’s a story for another day.

    Open ##1898359

  • @NohatCoder cache misses :(

    Open ##1898360

  • @cloudhop@equestria.social 2026-04-05 23:43

    @NohatCoder I was going to protest that there is no way this could possibly work, but even if you assume minecraft allocates 8 GB of memory every second, it would take 73 years to run out of address space, so if you just ignore memory region resizing optimizations...

    Open ##1898362