def report_memory(i=0):
 from matplotlib.compat.subprocess import Popen, PIPE
 pid = os.getpid()
 if (sys.platform == u'sunos5'):
  try:
   a2 = Popen((str(u'ps -p %d -o osz') % pid), shell=True, stdout=PIPE).stdout.readlines()
  except OSError:
   raise NotImplementedError(u"report_memory works on Sun OS only if the 'ps' program is found")
  mem = int(a2[(-1)].strip())
 elif sys.platform.startswith(u'linux'):
  try:
   a2 = Popen((str(u'ps -p %d -o rss,sz') % pid), shell=True, stdout=PIPE).stdout.readlines()
  except OSError:
   raise NotImplementedError(u"report_memory works on Linux only if the 'ps' program is found")
  mem = int(a2[1].split()[1])
 elif sys.platform.startswith(u'darwin'):
  try:
   a2 = Popen((str(u'ps -p %d -o rss,vsz') % pid), shell=True, stdout=PIPE).stdout.readlines()
  except OSError:
   raise NotImplementedError(u"report_memory works on Mac OS only if the 'ps' program is found")
  mem = int(a2[1].split()[0])
 elif sys.platform.startswith(u'win'):
  try:
   a2 = Popen([str(u'tasklist'), u'/nh', u'/fi', (u'pid eq %d' % pid)], stdout=PIPE).stdout.read()
  except OSError:
   raise NotImplementedError(u"report_memory works on Windows only if the 'tasklist' program is found")
  mem = int(a2.strip().split()[(-2)].replace(u',', u''))
 else:
  raise NotImplementedError((u"We don't have a memory monitor for %s" % sys.platform))
 return mem

def report_memory ( i = 0 ) : from matplotlib . compat . subprocess import Popen , PIPE pid = os . getpid ( ) if ( sys . platform == u'sunos5' ) : try : a2 = Popen ( ( str ( u'ps -p %d -o osz' ) % pid ) , shell = True , stdout = PIPE ) . stdout . readlines ( ) except OSError : raise NotImplementedError ( u"report_memory works on Sun OS only if the 'ps' program is found" ) mem = int ( a2 [ ( - 1 ) ] . strip ( ) ) elif sys . platform . startswith ( u'linux' ) : try : a2 = Popen ( ( str ( u'ps -p %d -o rss,sz' ) % pid ) , shell = True , stdout = PIPE ) . stdout . readlines ( ) except OSError : raise NotImplementedError ( u"report_memory works on Linux only if the 'ps' program is found" ) mem = int ( a2 [ 1 ] . split ( ) [ 1 ] ) elif sys . platform . startswith ( u'darwin' ) : try : a2 = Popen ( ( str ( u'ps -p %d -o rss,vsz' ) % pid ) , shell = True , stdout = PIPE ) . stdout . readlines ( ) except OSError : raise NotImplementedError ( u"report_memory works on Mac OS only if the 'ps' program is found" ) mem = int ( a2 [ 1 ] . split ( ) [ 0 ] ) elif sys . platform . startswith ( u'win' ) : try : a2 = Popen ( [ str ( u'tasklist' ) , u'/nh' , u'/fi' , ( u'pid eq %d' % pid ) ] , stdout = PIPE ) . stdout . read ( ) except OSError : raise NotImplementedError ( u"report_memory works on Windows only if the 'tasklist' program is found" ) mem = int ( a2 . strip ( ) . split ( ) [ ( - 2 ) ] . replace ( u',' , u'' ) ) else : raise NotImplementedError ( ( u"We don't have a memory monitor for %s" % sys . platform ) ) return mem
return the memory consumed by process .