Fix memory leak

Fix memory leak caused by setting `instruments = []` rather than `instruments.length = 0`.