import gc for x in list(locals().keys())[:]: del locals()[x] # del all_s_x, AE, AE_split, x_ticks, split gc.collect()