~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/trace.py

  • Committer: Karl Bielefeldt
  • Date: 2010-09-29 19:57:28 UTC
  • mto: (5483.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5484.
  • Revision ID: 7mq3cbbd9q@snkmail.com-20100929195728-nvuqlepsrwcxbziw
Use meliae to dump memory to a file upon MemoryError.

Show diffs side-by-side

added added

removed removed

Lines of Context:
469
469
                    note(line)
470
470
                    break
471
471
 
 
472
def _dump_memory_usage():
 
473
    try:
 
474
        from meliae import scanner
 
475
        scanner.dump_all_objects('bzr_memory_reference_dump.json')
 
476
        mutter("Dumped memory to bzr_memory_reference_dump.json")
 
477
    except ImportError:
 
478
        mutter("Unable to dump memory.  Please install the meliae module.")
 
479
        return
 
480
    except:
 
481
        mutter("Exception while dumping memory to bzr_memory_reference_dump.json")
472
482
 
473
483
def report_exception(exc_info, err_file):
474
484
    """Report an exception to err_file (typically stderr) and to .bzr.log.
491
501
        err_file.write("bzr: interrupted\n")
492
502
        return errors.EXIT_ERROR
493
503
    elif isinstance(exc_object, MemoryError):
 
504
        _dump_memory_usage()
494
505
        err_file.write("bzr: out of memory\n")
495
506
        return errors.EXIT_ERROR
496
507
    elif isinstance(exc_object, ImportError) \