implementation of dynamic memory alloctation

implement the dynamic memory allocation for each thread, if the server
run as a ‘one thread per connection’ mode, which can lead to a memory
consumption win in case of small available ram space