added logic to find out a good thread pool size which depends on the available free memory on running machine