In the current design all of the attributes are doing individual mallocs. That seems fine until you take into account the malloc granularity is 16b I think and often only 4b is used. There are other ways possible to allocate this memory. Since attribute buffers are fixed size you could use a single malloc per endpoint and assign the buffers from it. Then as more attributes are created do a realloc if necessary. This scheme works to eliminate all of the tiny mallocs. You'd need to do some experimentation to see if switching strategies is worth it.
My devices now have 42 endpoints and those endpoints trigger many thousands of tiny allocations. If 2,000 tiny allocations each lose 12 bytes, that is 24KB of lost memory. Of course I switched over to PSRAM long ago so I am not bothered by this.
In the current design all of the attributes are doing individual mallocs. That seems fine until you take into account the malloc granularity is 16b I think and often only 4b is used. There are other ways possible to allocate this memory. Since attribute buffers are fixed size you could use a single malloc per endpoint and assign the buffers from it. Then as more attributes are created do a realloc if necessary. This scheme works to eliminate all of the tiny mallocs. You'd need to do some experimentation to see if switching strategies is worth it.
My devices now have 42 endpoints and those endpoints trigger many thousands of tiny allocations. If 2,000 tiny allocations each lose 12 bytes, that is 24KB of lost memory. Of course I switched over to PSRAM long ago so I am not bothered by this.