Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. import resource
  2. from scipy.stats import rv_continuous
  3.  
  4. class Rv(rv_continuous):
  5.  
  6. def __init__(self, x):
  7. rv_continuous.__init__(self, a=0, b=1)
  8. self.x = x
  9.  
  10. def _pdf(self, y):
  11. return 1
  12.  
  13.  
  14. def call_rv(x):
  15. rv = Rv(x)
  16. # if the line below is commented out, memory usage stays constant
  17. s = rv.rvs()
  18. return 1
  19.  
  20. for k in range(10000):
  21. x = call_rv(k)
  22. if k%1000==0:
  23. print 'Memory usage: %s (kb)' % resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement