import matplotlib.pylab as plt for x in xrange(501): fig = plt.figure() print x segfaults in the last iteration. Do you experience the same?