LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Functions
lsst.daf.base.citizen Namespace Reference

Functions

def setCallbacks
 
def mortal
 

Function Documentation

def lsst.daf.base.citizen.mortal (   memId0 = 0,
  nleakPrintMax = 20,
  first = True,
  showTypes = None 
)
Print leaked memory blocks
@param memId0 Only consider blocks allocated after this memId
@param nleakPrintMax Maximum number of leaks to print; <= 0 means unlimited
@param first Print the first nleakPrintMax blocks; if False print the last blocks.
@param showTypes Only print objects matching this regex (if starts with !, print objects that don't match)

If you want finer control than nleakPrintMax/first provide, use
dafBase.Citizen.census() to get the entire list

You can get the next memId to be allocated with mortal("set"), e.g.
memId0 = mortal("set")
# work work work
mortal(memId0)

Definition at line 29 of file citizen.py.

29 
30 def mortal(memId0=0, nleakPrintMax=20, first=True, showTypes=None):
31  """Print leaked memory blocks
32  @param memId0 Only consider blocks allocated after this memId
33  @param nleakPrintMax Maximum number of leaks to print; <= 0 means unlimited
34  @param first Print the first nleakPrintMax blocks; if False print the last blocks.
35  @param showTypes Only print objects matching this regex (if starts with !, print objects that don't match)
36 
37  If you want finer control than nleakPrintMax/first provide, use
38  dafBase.Citizen.census() to get the entire list
39 
40 You can get the next memId to be allocated with mortal("set"), e.g.
41  memId0 = mortal("set")
42  # work work work
43  mortal(memId0)
44  """
45 
46  if memId0 == 'set':
47  return dafBase.Citizen.getNextMemId()
48 
49  nleak = dafBase.Citizen.census(0, memId0)
50  if nleak != 0:
51  print "%d Objects leaked" % dafBase.Citizen.census(0, memId0)
52 
53  census = dafBase.Citizen.census()
54  census = [census[i].repr() for i in range(len(census))] # using [i] for some swiggy reason
55  if showTypes:
56  if showTypes[0] == '!':
57  invert = True # invert the matching logic
58  showTypes = showTypes[1:]
59  else:
60  invert = False
61 
62  _census, census = census, []
63  for c in _census:
64  memId, addr, dtype = c.split()
65  memId = int(memId[:-1])
66 
67  if \
68  (not invert and re.search(showTypes, dtype)) or \
69  (invert and not re.search(showTypes, dtype)):
70  census.append(c)
71 
72  nleak = len(census)
73  print "%d leaked objects match" % nleak
74 
75  if nleakPrintMax <= 0 or nleak <= nleakPrintMax:
76  for c in census:
77  memId, addr, type = c.split()
78  memId = int(memId[:-1])
79  if memId >= memId0:
80  print c
81  else:
82  print "..."
83  for i in range(nleakPrintMax - 1, -1, -1):
84  print census[i]
def lsst.daf.base.citizen.setCallbacks (   new = None,
  delete = None,
  both = False 
)
Set the callback IDs for the Citizen; if both is true, set both new and delete to the same value

You probably want to chant the following to gdb:
   break defaultNewCallback
   break defaultDeleteCallback

You might want to put this in your .gdbinit file.

You can retrieve a citizen's signature from python with obj.repr()

Definition at line 4 of file citizen.py.

4 
5 def setCallbacks(new=None, delete=None, both=False):
6  """Set the callback IDs for the Citizen; if both is true, set both new and delete to the same value
7 
8 You probably want to chant the following to gdb:
9  break defaultNewCallback
10  break defaultDeleteCallback
11 
12 You might want to put this in your .gdbinit file.
13 
14 You can retrieve a citizen's signature from python with obj.repr()
15  """
16 
17  if both:
18  if new:
19  if delete and new != delete:
20  raise RuntimeError, "You may not specify new, delete, and both"
21  delete = new
22  else:
23  new = delete
24 
25  if new:
26  dafBase.Citizen.setNewCallbackId(new)
27  if delete:
28  dafBase.Citizen.setDeleteCallbackId(delete)