check buildThreshold for the memory leak problem
add more memory free function
update the memory clean function