when -j is used, clear memory before go to the next one to save memory