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

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