Using for Debug, finding problem
Project description
1、介绍
本工具用与日志记录python程序内存信息,包括内存对象数量(memory type num),内存对象增长(memory type num increment),以及堆内存信息(memory heap info)。
2、使用方式
示例:
import time
import debug_util
class Int:
def __init__(self, value):
self.value = value
def new_int(i1, rs1):
a = Int(i1)
rs1.append(a)
if __name__ == '__main__':
ml = debug_util.memory_logger(log_file_name='test', duration=2)
ml.add_target(debug_util.handlers.MEMORY_TYPE_NUM)
ml.add_target(debug_util.handlers.MEMORY_TYPE_NUM_GROWTH)
ml.add_target(debug_util.handlers.MEMORY_STACK)
ml.start()
rs = []
i = 0
while True:
if i % 1000000 == 0:
time.sleep(2)
if i == 10000000:
break
new_int(i, rs)
i += 1
查看log/test.log文件
=== types: 2022-04-06 15:19:54.733344 ===
Int 1000000
function 7643
dict 4543
tuple 3687
weakref 3487
wrapper_descriptor 2308
list 2288
set 1516
method_descriptor 1392
getset_descriptor 1117
=== increments: 2022-04-06 15:19:56.057061 ===
Int 1601726 +1601726
function 7643 +7643
dict 4543 +4543
tuple 3686 +3686
weakref 3488 +3488
wrapper_descriptor 2308 +2308
list 2288 +2288
set 1516 +1516
method_descriptor 1392 +1392
getset_descriptor 1117 +1117
=== heap: 2022-04-06 15:19:57.694068 ===
Partition of a set of 6196589 objects. Total size = 432261651 bytes.
Index Count % Size % Cumulative % Kind (class / dict of class)
0 2016955 33 225898960 52 225898960 52 dict of __main__.Int
1 2016955 33 112949480 26 338848440 78 __main__.Int
2 2019998 33 56568872 13 395417312 91 int
3 2165 0 17903984 4 413321296 96 list
4 45089 1 6041583 1 419362879 97 str
5 35822 1 2708928 1 422071807 98 tuple
6 17286 0 1296554 0 423368361 98 bytes
7 8675 0 1254272 0 424622633 98 types.CodeType
8 8439 0 1147704 0 425770337 98 function
9 1116 0 984664 0 426755001 99 type
<393 more rows. Type e.g. '_.more' to view.>
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
duyan-debug-0.0.6.tar.gz
(41.0 kB
view details)
Built Distribution
File details
Details for the file duyan-debug-0.0.6.tar.gz
.
File metadata
- Download URL: duyan-debug-0.0.6.tar.gz
- Upload date:
- Size: 41.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.6.0 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6eb238c0d56e0024546872d1abdbe57aa3536eafabcf4c05a661f3398e51b23 |
|
MD5 | 848651a19dec1c95942b176e0fcf3e10 |
|
BLAKE2b-256 | e2c9e887b58ede995bbb91e1b4d5491e2b9dcd9cec98893991035c8301625a43 |
File details
Details for the file duyan_debug-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: duyan_debug-0.0.6-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.6.0 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d291abbcbf6acc8b2fa58174f54904b4d0d93e1642e764fc064841e26022988a |
|
MD5 | 5a9bc18915d42c05c743926012e1784e |
|
BLAKE2b-256 | 4f0ae42483258d8f1cde3a68e3cc2f035713c8010f77d4a5413b675722ed0293 |