Timeline for Game Engine Memory Allocator
Current License: CC BY-SA 4.0
12 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Apr 12, 2020 at 0:00 | history | tweeted | twitter.com/StackGameDev/status/1249125164664721409 | ||
| Apr 11, 2020 at 19:48 | history | became hot network question | |||
| Apr 11, 2020 at 12:21 | vote | accept | Sammi3 | ||
| Apr 11, 2020 at 12:19 | answer | added | Ted Klein Bergman | timeline score: 4 | |
| Apr 11, 2020 at 12:16 | comment | added | Ted Klein Bergman | @DMGregory Yeah, I realised that. Composing an answer now :P | |
| Apr 11, 2020 at 12:15 | comment | added | DMGregory♦ | @TedKleinBergman: I think it would be worthwhile to put this kind of information in an Answer below. I'd upvote it. :) | |
| Apr 11, 2020 at 12:12 | comment | added | Ted Klein Bergman |
They talk about it a little in the gamasutra link under Memory Manager Types in Games. Basically, you identify an issue and try to solve that issue. Their example is that when you render a scene, you use a lot of memory that are not needed in the next frame. Instead of constantly asking for memory and freeing memory each frame, you allocate a chunk of memory that you just reuse every scene. Very common. The basic rule is that calling the kernel/OS for memory (using new or malloc) is slow, so you should do this as little as possible.
|
|
| Apr 11, 2020 at 12:05 | comment | added | Ted Klein Bergman | Yes, basically. Although, many allocators works well in many different circumstances and can be reused. But remember that memory allocation is an optimisation, so you should often profile your use-case before implementing a more specific allocator. If you notice that your game is slow iterating through entities because they're scattered around in memory, you should probably change to an allocator that pack things tightly. But if you then notice that the overhead of packing the entities cost more performance, you should change to another allocator. It's a challenge of weighing pros and cons | |
| Apr 11, 2020 at 11:57 | comment | added | Sammi3 | @TedKleinBergman Well currently just need to use it for PhysX as PhysX requires a memory allocator but it would be good to learn about this as I aspire to be an Engine Programmer. So what I'm getting is that I create allocators on a case by case basis for different resources? | |
| Apr 11, 2020 at 11:54 | comment | added | Ted Klein Bergman |
What kind, and how many, allocators you need depends on what you're doing with memory. If you want a particle system, then you should probably create a pool allocator, as it's often the most efficient for the job. If you have assets that are loaded and unloaded sporadically, you'll need a more dynamic allocator (which is often less performant). So it all depends on exactly how your game works. Many smaller games uses only heap allocation (new or malloc) and works fine. Custom memory allocation is an optimisation and dependent on your specific use-case (although, there are commonalities).
|
|
| Apr 11, 2020 at 11:48 | comment | added | DMGregory♦ | You may find this GDC talk on building a memory system useful. | |
| Apr 11, 2020 at 11:43 | history | asked | Sammi3 | CC BY-SA 4.0 |