Improve data manager performance

- limit the use of malloc and free
- reduce context switching with optimized use of locks