Hacker News new | ask | show | jobs
by markisus 110 days ago
Yeah if your program has a natural notion of a "frame" (eg most video games), you can do memory management by simply incrementing an integer (bump allocation). At the end of your frame, you reset the integer to zero. You can't really get any faster than that.

An additional benefit of this style of allocation over malloc/free is that you can get a lot of the same type of objects contiguous in memory so that iteration over them is a lot faster because there are fewer cache misses.

1 comments

What is a 'frame'? Are you referring to the stack frame?
Like what you mean when you say “frames per second” in a video game. The image that is finally presented to the user, and then quickly thrown away and rebuilt, again and again to give the illusion of motion.