a simple mem pool sample, you can alloc mem unless there is no memory . free the memory which you alloc from mempool is very fast.