I need a thread-unsafe, lockless malloc to use it in a single threaded application. I expect to gain a little performance boost because of this. I need it on win and linux, and it must guaranteed to be single-threaded. Any ideas?
Have you actually profiled your code and shown that it's spending a significant portion of its time in malloc? I would say instead of a replacement malloc, first consider an alternate algorithm that doesn't do as much dynamic allocation. If that's not an option I would consider a memory pool approach (they can be very fast with fixed-size blocks).
To answer the question, some implementations have compiler options to remove the thread safety from malloc. This answer: Is malloc thread-safe? suggests that NO_THREADS can be defined to remove the thread-safety from malloc, but I have not tested this.
You should listen to the other posts, however, it is unlikely to be the best place to start your optimisiations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With