Skip to main content

Python tool for diagnosing memory leaks.

Project description

A SmartFile Open Source project. Read more about how SmartFile uses and contributes to Open Source software.

SmartFile

Introduction

This package consists of a library and command line tool. The library allows you to dump the Python objects in memory to a dump file.

The command line tool is used to examine the dump file contents.

Creating a dump file.

To add memory dump capability to one of your Python applications, import the caulk library and register a signal handler.

import caulk

caulk.handler()

A number of kwargs can control the operation of the signal handler.

  • signum - The signal to react to, signal.SIGUSR1 by default.

  • path - The path to which to write the dump file /var/tmp by default.

  • name - The name of the dump file, ‘caulk’ by default..

A dump file’s name will be: ‘{0}-{1}-{2}.dump’.format(name, pid, time).

To generate a dump file, use kill:

# kill -usr1 <pid>

Where <pid> is the pid of your running application.

You can also use the low-level API to generate a dump file directly instead of relying on a signal handler.

import caulk

caulk.dump('/var/tmp/my.dump')

Examining a dump file.

To examine the dump file, use the caulk command.

# caulk --classes /var/tmp/caulk-1025-1346255743.435316.dump
count total  average min/max   class
----------------------------------------------------------------------
4     256    64      64/64     unittest.suite.TestSuite
1     64     64      64/64     unittest.runner._WritelnDecorator
1     64     64      64/64     site._Helper
...

For more information on using the caulk command, see it’s help.

# caulk --help

Project details


Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page