def get_leaking_objects(objects=None):
 if (objects is None):
  gc.collect()
  objects = gc.get_objects()
 try:
  ids = set((id(i) for i in objects))
  for i in objects:
   ids.difference_update((id(j) for j in gc.get_referents(i)))
  return [i for i in objects if (id(i) in ids)]
 finally:
  del objects, i

def get_leaking_objects ( objects = None ) : if ( objects is None ) : gc . collect ( ) objects = gc . get_objects ( ) try : ids = set ( ( id ( i ) for i in objects ) ) for i in objects : ids . difference_update ( ( id ( j ) for j in gc . get_referents ( i ) ) ) return [ i for i in objects if ( id ( i ) in ids ) ] finally : del objects , i
return objects that do not have any referents .