I had an idea and am wondering whether it already exists, and if not whether there is a good reason it does not, ie is it a terrible idea?
The idea is this: an allocator that is not unlike an arena allocator, but is
'static so memory can never be freed. The allocated data is immutable, and is stable in the sense that a given data item will be always given the same pointer (on a given run of the program). Obviously this requires a type that is Hash and Eq in order to be efficient. The purpose of all this is that the allocated pointers could be both Eq and Copy, with pointer equality reflecting value equality. This combination seems like it would be very convenient as well as efficient for tree like types that are frequently placed in sets or used as keys for maps. Particularly when there is a lot of redundancy between parts of trees, sticky that the deduplication compensates somewhat for the perpetual leaking of memory.
The implementation would need to use a hash map to keep track of all the allocated data and to ensure that a given value corresponds to a unique pointer.
Thoughts? Does this thing have a name or an existing implementation?