add max memory and unfreed memory check function in script