ZigGBA
ZigGBA copied to clipboard
Add `Allocator` API
An allocator that can keep track of the available memory in a given region would be very useful, particularly for relatively small and potentially sparsely populated regions such as oam. This would ideally include:
- General purpose allocator for wram
- Generic allocator specialized to individual regions optimized for particular types (object attributes, tile data, etc.)
- An overarching allocator wrapping all of these for all library types, potentially using the
std.Allocatorinterface.
If a general-purpose allocator is too bloated or slow, we should at least expose an API by which users can insert their own allocation strategies optimized for their use case.
Planned features (open to discussion):
- [ ] Create and manage fixed-size pools of memory with different replacement/update strategies. It's rare to want to manage all object types the same way: sometimes you want an instantiation to replace an existing item, and sometimes you want it to just fail silently. LRU, LFU, and other Eviction strategies would be good to include at the library level.