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))