scoat2
❔ “Mini” references? (Managed references with less than 32/64bit pointers. 8bit for example)
Summary: I’m wondering if there’s a way to leverage C#’s amazing automatic garbage collection system for collections of objects that will not exceed let’s say, 256 objects in length (that would make 8bit references possible). I’d like to be able to just easily create a “short” reference type. Maybe there’s an easy way to do that built in to C# and I just don’t know about it.
Example problem: (skinned mesh)
I have a mesh made of thousands of vertices. Each vertex has 4 bone references. Currently each bone is represented as an integer index into an array of bones, since it’s more lightweight. The problem is any time I want to add or remove bones, I need to process every vertex and update each index. This is totally possible but very cumbersome. Essentially I’ll end up building a system that mimics C#’s GC system, which automatically compacts the heap and updates all necessary pointers internally. This is basically analogous to what my bone system would end up doing (just swap heap for array of bones, and integer indices for pointers). Let’s say there will only ever be a maximum of 255 bones. In that case it would make sense to use managed references with 8bit pointers instead of 32/64bit, because each reference is copied thousands (or maybe millions) of times for each vertex.
Second super simple example: Let’s say you have a million references, but each only references one of 8 distinct objects. It would save a ton of memory to use 3bit references instead of 32bit. (3 million bits vs 32 million).
I don’t want to recode a system if it already exists. It makes sense that someone might want to use “mini/lightweight managed references” if they want to use memory efficiently in certain cases.
2 replies