bs_mem module¶
Reports on memory usage:
mem_usage: prints the topnlargest global items in memorymemory_display_top: prints the topnlargest memory allocations since tracing startedmemory_display_top_diffs: prints the topnlargest memory allocations since the last snapshot.
memory_display_top(snapshot, key_type='lineno', limit=5)
¶
prints out the lines with the top limit allocations of memory since
tracemalloc.start()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot
|
Snapshot
|
obtained from tracemalloc.take_snapshot() |
required |
key_type
|
str
|
'lineno' gives file and line number; 'traceback' gives all |
'lineno'
|
limit
|
int | None
|
how many top allocations we want |
5
|
Returns:
| Type | Description |
|---|---|
None
|
just prints. |
Examples:
1 2 3 4 | |
Source code in bs_python_utils/bs_mem.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
memory_display_top_diffs(snapshot1, snapshot2, key_type='lineno', limit=5)
¶
prints out the lines with the top limit allocations between the two snapshots
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot1
|
Snapshot
|
previous snapshot |
required |
snapshot2
|
Snapshot
|
new snapshot |
required |
key_type
|
str
|
'lineno' gives file and line number; 'traceback' gives all |
'lineno'
|
limit
|
int
|
how many top allocations we want |
5
|
Returns:
| Type | Description |
|---|---|
None
|
just prints. |
Examples:
1 2 3 4 5 6 | |
Source code in bs_python_utils/bs_mem.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
memory_usage(n=10)
¶
prints the top n largest global items in memory
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int | None
|
we report the size of the largest |
10
|
Returns:
| Type | Description |
|---|---|
None
|
nothing. |
Source code in bs_python_utils/bs_mem.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |