Skip to content

Implement accurate size storage for Windows _msize and _recalloc #786

Open

Description

With snmalloc we can provide a custom meta-data per object that is attached to the standard snmalloc meta-data such as free lists.

struct ArrayClientMetaDataProvider
{
using StorageType = T;
using DataRef = T&;
static size_t required_count(size_t max_count)
{
return max_count;
}
static DataRef get(StorageType* base, size_t index)
{
return base[index];
}
};

We could use this feature to store a single bit per object. The bit being set means the allocation does not consume the whole allocated space. The last byte then represents how much space is not being used by the allocation, i.e. 17 byte allocation, would have the last byte as 15 (32 - 17) and the bit would be set, whereas a 32 byte allocation would not have the bit set.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions