cinera_handmade.network/cmuratori/hero/code/code157.hmml

36 lines
3.7 KiB
Plaintext
Raw Permalink Normal View History

[video output=day157 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Introduction to General Purpose Allocation" vod_platform=youtube id=MvDUe2evkHg annotator=ZedZull annotator=debiatan]
[00:00:18][Plan for today]
[00:01:28][Our asset memory management problem can't be solved by a garbage collector]
[00:02:36][Asset memory management (blackboard)]
[00:03:40][A good way to think about memory management]
[00:10:04][The amount of memory we need is larger than the amount of memory we have. We have a Virtual Memory problem.]
[00:15:01][Stacks and GC can't help us in this situation]
[00:16:32][Memory fragmentation]
[00:19:20][In a world were all the assets were the same size...]
[00:21:20][In our case assets are not the same size, but we could find ways around that]
[00:23:35][We could have a big sprite sheet and page the chunks in when they were needed (similar to Megatexture)]
[00:27:54][Another option: A variable allocator. It could defragment memory or merge contiguous freed spaces. We're choosing this one for educational reasons]
[00:31:36][Overview of the variable allocator]
[00:34:18][Running out of memory on purpose]
[00:37:14][Restructuring loaded_bitmap and loaded_sound to move asset data inside asset_slots]
[00:49:41][Moving asset data inside asset_slots]
[00:52:54][Determining ahead of time when we're going to hit our memory limit]
[00:54:00][We can't free assets to make room for new ones from inside a call to LoadBitmap]
[00:55:35][We can mark bitmaps as freed between frames. Two options: a) deferring LoadBitmap calls till the end of the frame and b) keeping some amount of free space to make loading always possible]
[00:57:44][Q&A][:speech]
[00:57:57][@pseudonym73][It's official: Assets are now handles]
[00:58:37][@robotchocolatedino][Would there be a benefit to using a 2-level cache for storing compressed and uncompressed assets?]
[00:59:35][@marumoto][Is there any performance reason to not use malloc and free?]
[01:00:52][@gasto5][Are there technical terms for the memory emptiness assurance algorithm?]
[01:01:17][@duel1000][Can you talk a bit about what new / delete actually does and when to use them?]
[01:12:33][@pseudonym73][Could you briefly comment on how viable it would be to recast the problem as one of asset packing? Split sounds into fixed-sized chunks and dice bitmaps into fixed-size tiles, so that all of the tiles are of a reasonable size. Group related assets together so they are loaded together. That sort of thing]
[01:14:16][@zouchk42][Is there a real "philosophy" difference between using smart pointers and garbage collection? Or are smart pointers just a way to implement garbage collection?]
[01:19:32][@thesizik][What about RAII?]
[01:29:42][@gasto5][How about vibration effect assets?]
[01:29:50][@soysaucethekid][What is the difference between a megatexture and a texture atlas?]
[01:30:33][@plain_flavored][Do you object to use of explicit vtables, like you would have to use in C?]
[01:31:15][@starchypancakes][Would thinking about asset allocation in terms of the maximum amount of pixels that can be displayed on screen at one time be worth it (for instance with your 16MB safety buffer). So you tailor the asset loading to load assets at a resolution proportional to the distance to the camera and operate under the assumption that only a fixed number of things can "physically" occupy the high-res space and so on for medium, low, etc.]
[01:32:33][@pseudonym73][(Referring to Q at 01:12:33) The thing I didn't see was grouping small related assets together so they fit in one allocation unit.]
[01:33:04][@gaudongaming][Is this still the same blackboard file from day 1? Is there a fully zoomed out view and how much RAM is that program consuming now with all your current doodles?]
[/video]