title: How can I clear ram after each for loops?
body: <p>The following code is the piece of code for create noisy audio signal from clean signal but when I ran it , my memory was filling and Spyder freezed. The whole of my audio data file is 2G. How can I clean my memory across the running code or the end of for loop?</p>
  
  <pre><code>for i in range(len(path_wav)):
      clean_file.append(path_wav[i])
      clean_wav.append(wave.open(clean_file[i], "r"))
      clean_amp.append(cal_amp(clean_wav[i]))
      clean_rms.append(cal_rms(clean_amp[i]))
      divided_noise_amp.append(np.resize(noise_amp,len(clean_amp[i])))
      noise_rms.append(cal_rms(divided_noise_amp[i]))
      adjusted_noise_rms.append(cal_adjusted_rms(clean_rms[i], snr))
      adjusted_noise_amp.append(divided_noise_amp[i] * (adjusted_noise_rms[i] / noise_rms[i]))
      mixed_amp.append((clean_amp[i] + adjusted_noise_amp[i]))
      save_waveform(path_wav_out[i] , clean_wav[i].getparams(), mixed_amp[i])
  </code></pre>
  
  <p>Also,I break for loop to multi small loops but after running the first loop and memory isn't empty for another loops.</p>
  
  <pre><code>for i in range(0,int(len(path_wav)/10)):
      clean_file.append(path_wav[i])
      clean_wav.append(wave.open(clean_file[i], "r"))
      clean_amp.append(cal_amp(clean_wav[i]))
      clean_rms.append(cal_rms(clean_amp[i]))
      divided_noise_amp.append(np.resize(noise_amp,len(clean_amp[i])))
      noise_rms.append(cal_rms(divided_noise_amp[i]))
      adjusted_noise_rms.append(cal_adjusted_rms(clean_rms[i], snr))
      adjusted_noise_amp.append(divided_noise_amp[i] * (adjusted_noise_rms[i] / noise_rms[i]))
      mixed_amp.append((clean_amp[i] + adjusted_noise_amp[i]))
      save_waveform(path_wav_out[i] , clean_wav[i].getparams(), mixed_amp[i])
  for i in range(int(len(path_wav)/10),int(2*len(path_wav)/10)):
      clean_file.append(path_wav[i])
      clean_wav.append(wave.open(clean_file[i], "r"))
      clean_amp.append(cal_amp(clean_wav[i]))
      clean_rms.append(cal_rms(clean_amp[i]))
      divided_noise_amp.append(np.resize(noise_amp,len(clean_amp[i])))
      noise_rms.append(cal_rms(divided_noise_amp[i]))
      adjusted_noise_rms.append(cal_adjusted_rms(clean_rms[i], snr))
      adjusted_noise_amp.append(divided_noise_amp[i] * (adjusted_noise_rms[i] / noise_rms[i]))
      mixed_amp.append((clean_amp[i] + adjusted_noise_amp[i]))
      save_waveform(path_wav_out[i] , clean_wav[i].getparams(), mixed_amp[i])
  </code></pre>