Closed rHermes closed 2 months ago
I'm testing more now, and this doesn't really work at all, even with the given fix.
The current approach of using a std::shared_ptr
to manage the heap only works if we are going to call a destructor on it. We also have to change the deleter when constructing. I'll do that and add tests for this and push again.
@microsoft-github-policy-service agree
@daanx requesting a PR here, if you have the time :)
Hi @rHermes -- just to confirm, this is only a problem for mi_heap_destroy_stl_allocator
right? (On msvc 2022 I only get errors on the "destroy" variant).
This would be great to fix.. but we cannot pull in mimalloc/types.h
as that breaks the abstraction barrier where mi_heap_t
should be abstract. I guess you pulled it in to make the sizeof
operation in the static assertion pass? Is there another way we could make this work where we do not include the internal mimalloc/types.h
header file?
Maybe we should not use std::shared_ptr
? Or perhaps use a wrapper struct around a mi_heap_t*
?
Hey!
Yes the problem is only for mi_heap_destroy_stl_allocator
and it's only when you pass in a heap type. The problem here is that shared_ptr
is a perfect type for this, as the allocator might live on in objects created with it, like std::vector
or others. I think the approach works well and I don't think it should be changed.
I don't really know about the internals of mimalloc, so I don't know about why it needs to be upheld, but I will try some ways to do it, without including the type! I'll comment back when I either push a new version or give up ;)
Ok, that was quick. I don't know why I included the type initially, but it's not needed. I've removed it now and it's good!
ah that's great. Testing now
Thanks so much!
Before it would not work to create the
mi_heap_stl_allocator
types with passing in ami_heap_t*
, sincesizeof
is used and it gives a compilation error. This change fixes that.Steps to reproduce the current error:
Compilation error is: