def get_mem_used_res():
 try:
  import resource
 except ImportError:
  raise NotSupportedException
 a = os.popen(('cat /proc/%s/statm' % os.getpid())).read().split()
 if (not (len(a) > 1)):
  raise NotSupportedException
 return (int(a[1]) * resource.getpagesize())

def get_mem_used_res ( ) : try : import resource except ImportError : raise NotSupportedException a = os . popen ( ( 'cat /proc/%s/statm' % os . getpid ( ) ) ) . read ( ) . split ( ) if ( not ( len ( a ) > 1 ) ) : raise NotSupportedException return ( int ( a [ 1 ] ) * resource . getpagesize ( ) )
this only works on linux .