Code Search for Developers
 
 
  

memleak_hawaii3.py from matplotlib at Krugle


Show memleak_hawaii3.py syntax highlighted

#!/usr/bin/env python

import os, sys, time, gc
import matplotlib
matplotlib.use('Agg')

from matplotlib.cbook import report_memory
import matplotlib.numerix as nx
from pylab import figure, show, close

# take a memory snapshot on indStart and compare it with indEnd

rand = nx.mlab.rand

indStart, indEnd = 200, 401
for i in range(indEnd):

    fig = figure(1)
    fig.clf()


    t1 = nx.arange(0.0, 2.0, 0.01)
    y1 = nx.sin(2*nx.pi*t1)
    y2 = rand(len(t1))
    X = rand(50,50)

    ax = fig.add_subplot(221)
    ax.plot(t1, y1, '-')
    ax.plot(t1, y2, 's')


    ax = fig.add_subplot(222)
    ax.imshow(X)

    ax = fig.add_subplot(223)
    ax.scatter(rand(50), rand(50), s=100*rand(50), c=rand(50))

    ax = fig.add_subplot(224)
    ax.pcolor(10*rand(50,50))

    fig.savefig('tmp%d' % i, dpi = 75)
    close(1)

    gc.collect()
    val = report_memory(i)
    print i, val
    if i==indStart: start = val # wait a few cycles for memory usage to stabilize

end = val
print 'Average memory consumed per loop: %1.4fk bytes\n' % ((end-start)/float(indEnd-indStart))





See more files for this project here

matplotlib

Matplotlib is a pure python plotting library with the goal of making\r\npublication quality plots using a syntax familiar to matlab users. \r\nThe library uses Numeric for handling large\r\ndata sets and supports a variety of output backends

Project homepage: http://sourceforge.net/projects/matplotlib
Programming language(s): C,C++,Python
License: other

  pathologies/
    const_xy.py
    shapes.py
    single_date.py
    single_point.py
    test.py
  __init__.py
  agg_memleak.py
  auto_legend.py
  dates_unit.py
  ft2font_memleak.py
  helpers.py
  inside_poly_memleak.py
  inside_poly_profile.py
  legend_unit.py
  longs_test.py
  memleak_gui.py
  memleak_hawaii3.py
  memleak_nongui.py
  memleak_transforms.py
  override_builtins.py
  simple_plot.py
  test_wxagg.py
  transform_memleak.py
  transforms_unit.py