l.s.p.mem : module documentation

Part of lp.services.profile

This code is from:
    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/286222
    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65333
This is under the Python Licence.

It also contains spiv's code from:
    http://twistedmatrix.com/users/spiv/countrefs.py
This is under 'MIT Licence if I'm pressed'

None of this should be in day-to-day use. Feel free to document usage
and improve APIs as needed.
Function memory Return memory usage in bytes.
Function resident Return resident memory usage in bytes.
Function stacksize Return stack size in bytes.
Function dump_garbage show us what's the garbage about
Function classesWithMostRefs Return the n ClassType objects with the highest reference count.
Function mostRefs Return the n types with the highest reference count.
Function countsByType Return the n types with the highest instance count in a list.
Function deltaCounts Compare two references counts lists and return the increase.
Function printCounts Undocumented
Function readCounts Reverse of printCounts().
Function logInThread Undocumented
Function _VmB Private.
Function _logRefsEverySecond Undocumented
def _VmB(VmKey):
Private.
def memory(since=0.0):
Return memory usage in bytes.
def resident(since=0.0):
Return resident memory usage in bytes.
def stacksize(since=0.0):
Return stack size in bytes.
def dump_garbage():
show us what's the garbage about

import gc gc.enable() gc.set_debug(gc.DEBUG_LEAK)

def classesWithMostRefs(n=30):
Return the n ClassType objects with the highest reference count.

This gives an idea of the number of objects in the system by type, since each instance will have at lest one reference to the class.

ReturnsA list of tuple (count, type).
def mostRefs(n=30):
Return the n types with the highest reference count.

This one uses a different algorithm than classesWithMostRefs. Instead of retrieving the number of references to each ClassType, it counts the number of objects returned by gc.get_objects() and aggregates the results by type.

ReturnsA list of tuple (count, type).
def countsByType(objects, n=30):
Return the n types with the highest instance count in a list.

This takes a list of objects and count the number of objects by type.

def deltaCounts(counts1, counts2, n=30):
Compare two references counts lists and return the increase.
def printCounts(counts, file=None):
Undocumented
def readCounts(file, marker=None):
Reverse of printCounts().

If marker is not None, this will return the counts as soon as a line containging is encountered. Otherwise, it reads until the end of file.

def logInThread(n=30):
Undocumented
def _logRefsEverySecond(log, n):
Undocumented
API Documentation for Launchpad, generated by pydoctor at 2018-11-17 00:00:08.