code: def generate_object_graphs_by_class(classlist):
      
      try:
          import objgraph
          import gc
      except ImportError:
          return
      graphcount = 0
      if not isinstance(classlist, list):
          classlist = [classlist]
      for class_item in classlist:
          for obj in gc.get_objects():
              if isinstance(obj, class_item):
                  graphcount += 1
                  objgraph.show_refs([obj], filename='%d_%s_%d_refs.png' % (
                      ogcounter, obj.__class__.__name__, graphcount))
                  objgraph.show_backrefs([obj], filename='%d_%s_%d_backrefs.png' % (
                      ogcounter, obj.__class__.__name__, graphcount))
docs: Generate reference and backreference graphs
      for objects of type class for each class given in classlist.
      Useful for debugging reference leaks in framework etc.
  
      Usage example to generate graphs for class "someclass":
      >>> import someclass
      >>> someclassobject = someclass()
      >>> generate_object_graphs_by_class(someclass)
  
      Needs "objgraph" module installed.