def clear(self):
        """
        Removes all modes from the editor. All modes are removed from list
        and deleted.

        """
        import sys
        while len(self._modes):
            key = sorted(list(self._modes.keys()))[0]
            mode = self.remove(key)
            refcount = sys.getrefcount(mode)
            if refcount > 2:
                try:
                    import objgraph
                except __HOLE__:
                    _logger().warning(
                        'potential memory leak detected on mode %r...\n'
                        'Install the objgraph package to know what objects are'
                        ' holding references the mode.' % mode)
                else:
                    _logger().warning(
                        'potential memory leak detected on mode: %r.\n'
                        'see stderr for a backrefs dot graph...' % mode)
                    objgraph.show_backrefs([mode], output=sys.stderr)
            del mode
dataset/ETHPy150Open OpenCobolIDE/OpenCobolIDE/open_cobol_ide/extlibs/pyqode/core/managers/modes.py/ModesManager.clear