Custom allocators?


#1

forgive me if I overlooked something; I only did a quick 1st glance test of ChaiScript (which I find a stunning project btw).

If I implement a tight loop (count to 1 million and sum everything up, for instance), I seem to notice a new shared_ptr for every variable assignment in the loop. That’s cool, this is how we do things in C++. Still, I’d like to be able to provide my own allocator for all memory management during an eval() call. There are allocation methods that beat malloc / free by a factor of 1000. Plus it’d help in cases where memory allocation is a tricky business (embedded systems with dubious or restricted heap memory or strictly non-blocking realtime requirements).

So please: can we have custom allocators?


#2

Agreed. For games, it can be a major pain point that new/delete gets called because of executing scripts.

Also note that now that we have Polymorphic Allocators, it’s a great time to allow them in something like ChaiScript.


#3

Agreed that custom allocators would be good, but hooking them throughout the entire system would be very difficult, probably impractical in the current code base, unfortunately.


#4

At least under linux i think you can highjack new/delete/malloc and make it use intel’s tbb allocators. those are rather cool. and oss by now. there are other allocs around with similar capability, tcmalloc ie. but no idea about windows.