@@ -17,9 +17,8 @@ msgstr ""
17
17
"Generated-By : Babel 2.17.0\n "
18
18
19
19
#: ../../library/tracemalloc.rst:2
20
- #, fuzzy
21
20
msgid ":mod:`!tracemalloc` --- Trace memory allocations"
22
- msgstr ":mod:`tracemalloc` --- 메모리 할당 추적"
21
+ msgstr ":mod:`! tracemalloc` --- 메모리 할당 추적"
23
22
24
23
#: ../../library/tracemalloc.rst:9
25
24
msgid "**Source code:** :source:`Lib/tracemalloc.py`"
@@ -95,6 +94,18 @@ msgid ""
95
94
"for stat in top_stats[:10]:\n"
96
95
" print(stat)"
97
96
msgstr ""
97
+ "import tracemalloc\n"
98
+ "\n"
99
+ "tracemalloc.start()\n"
100
+ "\n"
101
+ "# ... 여러분의 응용 프로그램을 실행합니다 ...\n"
102
+ "\n"
103
+ "snapshot = tracemalloc.take_snapshot()\n"
104
+ "top_stats = snapshot.statistics('lineno')\n"
105
+ "\n"
106
+ "print(\" [ Top 10 ]\" )\n"
107
+ "for stat in top_stats[:10]:\n"
108
+ " print(stat)"
98
109
99
110
#: ../../library/tracemalloc.rst:55 ../../library/tracemalloc.rst:225
100
111
msgid "Example of output of the Python test suite::"
@@ -122,6 +133,25 @@ msgid ""
122
133
"/usr/lib/python3.4/sysconfig.py:411: size=48.0 KiB, count=1, average=48.0"
123
134
" KiB"
124
135
msgstr ""
136
+ "[ Top 10 ]\n"
137
+ "<frozen importlib._bootstrap>:716: size=4855 KiB, count=39328, "
138
+ "average=126 B\n"
139
+ "<frozen importlib._bootstrap>:284: size=521 KiB, count=3199, average=167 "
140
+ "B\n"
141
+ "/usr/lib/python3.4/collections/__init__.py:368: size=244 KiB, count=2315,"
142
+ " average=108 B\n"
143
+ "/usr/lib/python3.4/unittest/case.py:381: size=185 KiB, count=779, "
144
+ "average=243 B\n"
145
+ "/usr/lib/python3.4/unittest/case.py:402: size=154 KiB, count=378, "
146
+ "average=416 B\n"
147
+ "/usr/lib/python3.4/abc.py:133: size=88.7 KiB, count=347, average=262 B\n"
148
+ "<frozen importlib._bootstrap>:1446: size=70.4 KiB, count=911, average=79 "
149
+ "B\n"
150
+ "<frozen importlib._bootstrap>:1454: size=52.0 KiB, count=25, average=2131"
151
+ " B\n"
152
+ "<string>:5: size=49.7 KiB, count=148, average=344 B\n"
153
+ "/usr/lib/python3.4/sysconfig.py:411: size=48.0 KiB, count=1, average=48.0"
154
+ " KiB"
125
155
126
156
#: ../../library/tracemalloc.rst:69
127
157
msgid ""
@@ -161,6 +191,19 @@ msgid ""
161
191
"for stat in top_stats[:10]:\n"
162
192
" print(stat)"
163
193
msgstr ""
194
+ "import tracemalloc\n"
195
+ "tracemalloc.start()\n"
196
+ "# ... 여러분의 응용 프로그램을 시작합니다 ...\n"
197
+ "\n"
198
+ "snapshot1 = tracemalloc.take_snapshot()\n"
199
+ "# ... 메모리 누수를 일으키는 함수를 호출합니다 ...\n"
200
+ "snapshot2 = tracemalloc.take_snapshot()\n"
201
+ "\n"
202
+ "top_stats = snapshot2.compare_to(snapshot1, 'lineno')\n"
203
+ "\n"
204
+ "print(\" [ Top 10 differences ]\" )\n"
205
+ "for stat in top_stats[:10]:\n"
206
+ " print(stat)"
164
207
165
208
#: ../../library/tracemalloc.rst:95
166
209
msgid ""
@@ -192,6 +235,27 @@ msgid ""
192
235
"/usr/lib/python3.4/contextlib.py:38: size=67.2 KiB (+67.2 KiB), count=126"
193
236
" (+126), average=546 B"
194
237
msgstr ""
238
+ "[ Top 10 differences ]\n"
239
+ "<frozen importlib._bootstrap>:716: size=8173 KiB (+4428 KiB), count=71332"
240
+ " (+39369), average=117 B\n"
241
+ "/usr/lib/python3.4/linecache.py:127: size=940 KiB (+940 KiB), count=8106 "
242
+ "(+8106), average=119 B\n"
243
+ "/usr/lib/python3.4/unittest/case.py:571: size=298 KiB (+298 KiB), "
244
+ "count=589 (+589), average=519 B\n"
245
+ "<frozen importlib._bootstrap>:284: size=1005 KiB (+166 KiB), count=7423 "
246
+ "(+1526), average=139 B\n"
247
+ "/usr/lib/python3.4/mimetypes.py:217: size=112 KiB (+112 KiB), count=1334 "
248
+ "(+1334), average=86 B\n"
249
+ "/usr/lib/python3.4/http/server.py:848: size=96.0 KiB (+96.0 KiB), count=1"
250
+ " (+1), average=96.0 KiB\n"
251
+ "/usr/lib/python3.4/inspect.py:1465: size=83.5 KiB (+83.5 KiB), count=109 "
252
+ "(+109), average=784 B\n"
253
+ "/usr/lib/python3.4/unittest/mock.py:491: size=77.7 KiB (+77.7 KiB), "
254
+ "count=143 (+143), average=557 B\n"
255
+ "/usr/lib/python3.4/urllib/parse.py:476: size=71.8 KiB (+71.8 KiB), "
256
+ "count=969 (+969), average=76 B\n"
257
+ "/usr/lib/python3.4/contextlib.py:38: size=67.2 KiB (+67.2 KiB), count=126"
258
+ " (+126), average=546 B"
195
259
196
260
#: ../../library/tracemalloc.rst:109
197
261
msgid ""
@@ -242,6 +306,21 @@ msgid ""
242
306
"for line in stat.traceback.format():\n"
243
307
" print(line)"
244
308
msgstr ""
309
+ "import tracemalloc\n"
310
+ "\n"
311
+ "# 25프레임을 저장합니다\n"
312
+ "tracemalloc.start(25)\n"
313
+ "\n"
314
+ "# ... 여러분의 응용 프로그램을 실행합니다 ...\n"
315
+ "\n"
316
+ "snapshot = tracemalloc.take_snapshot()\n"
317
+ "top_stats = snapshot.statistics('traceback')\n"
318
+ "\n"
319
+ "# 가장 큰 메모리 블록을 꺼냅니다\n"
320
+ "stat = top_stats[0]\n"
321
+ "print(\" %s memory blocks: %.1f KiB\" % (stat.count, stat.size / 1024))\n"
322
+ "for line in stat.traceback.format():\n"
323
+ " print(line)"
245
324
246
325
#: ../../library/tracemalloc.rst:141
247
326
msgid ""
@@ -286,6 +365,40 @@ msgid ""
286
365
" File \" /usr/lib/python3.4/runpy.py\" , line 160\n"
287
366
" \" __main__\" , fname, loader, pkg_name)"
288
367
msgstr ""
368
+ "903 memory blocks: 870.1 KiB\n"
369
+ " File \" <frozen importlib._bootstrap>\" , line 716\n"
370
+ " File \" <frozen importlib._bootstrap>\" , line 1036\n"
371
+ " File \" <frozen importlib._bootstrap>\" , line 934\n"
372
+ " File \" <frozen importlib._bootstrap>\" , line 1068\n"
373
+ " File \" <frozen importlib._bootstrap>\" , line 619\n"
374
+ " File \" <frozen importlib._bootstrap>\" , line 1581\n"
375
+ " File \" <frozen importlib._bootstrap>\" , line 1614\n"
376
+ " File \" /usr/lib/python3.4/doctest.py\" , line 101\n"
377
+ " import pdb\n"
378
+ " File \" <frozen importlib._bootstrap>\" , line 284\n"
379
+ " File \" <frozen importlib._bootstrap>\" , line 938\n"
380
+ " File \" <frozen importlib._bootstrap>\" , line 1068\n"
381
+ " File \" <frozen importlib._bootstrap>\" , line 619\n"
382
+ " File \" <frozen importlib._bootstrap>\" , line 1581\n"
383
+ " File \" <frozen importlib._bootstrap>\" , line 1614\n"
384
+ " File \" /usr/lib/python3.4/test/support/__init__.py\" , line 1728\n"
385
+ " import doctest\n"
386
+ " File \" /usr/lib/python3.4/test/test_pickletools.py\" , line 21\n"
387
+ " support.run_doctest(pickletools)\n"
388
+ " File \" /usr/lib/python3.4/test/regrtest.py\" , line 1276\n"
389
+ " test_runner()\n"
390
+ " File \" /usr/lib/python3.4/test/regrtest.py\" , line 976\n"
391
+ " display_failure=not verbose)\n"
392
+ " File \" /usr/lib/python3.4/test/regrtest.py\" , line 761\n"
393
+ " match_tests=ns.match_tests)\n"
394
+ " File \" /usr/lib/python3.4/test/regrtest.py\" , line 1563\n"
395
+ " main()\n"
396
+ " File \" /usr/lib/python3.4/test/__main__.py\" , line 3\n"
397
+ " regrtest.main_in_temp_cwd()\n"
398
+ " File \" /usr/lib/python3.4/runpy.py\" , line 73\n"
399
+ " exec(code, run_globals)\n"
400
+ " File \" /usr/lib/python3.4/runpy.py\" , line 160\n"
401
+ " \" __main__\" , fname, loader, pkg_name)"
289
402
290
403
#: ../../library/tracemalloc.rst:178
291
404
msgid ""
@@ -349,6 +462,39 @@ msgid ""
349
462
"snapshot = tracemalloc.take_snapshot()\n"
350
463
"display_top(snapshot)"
351
464
msgstr ""
465
+ "import linecache\n"
466
+ "import os\n"
467
+ "import tracemalloc\n"
468
+ "\n"
469
+ "def display_top(snapshot, key_type='lineno', limit=10):\n"
470
+ " snapshot = snapshot.filter_traces((\n"
471
+ " tracemalloc.Filter(False, \" <frozen importlib._bootstrap>\" ),\n"
472
+ " tracemalloc.Filter(False, \" <unknown>\" ),\n"
473
+ " ))\n"
474
+ " top_stats = snapshot.statistics(key_type)\n"
475
+ "\n"
476
+ " print(\" Top %s lines\" % limit)\n"
477
+ " for index, stat in enumerate(top_stats[:limit], 1):\n"
478
+ " frame = stat.traceback[0]\n"
479
+ " print(\" #%s: %s:%s: %.1f KiB\" \n"
480
+ " % (index, frame.filename, frame.lineno, stat.size / 1024))\n"
481
+ " line = linecache.getline(frame.filename, frame.lineno).strip()\n"
482
+ " if line:\n"
483
+ " print(' %s' % line)\n"
484
+ "\n"
485
+ " other = top_stats[limit:]\n"
486
+ " if other:\n"
487
+ " size = sum(stat.size for stat in other)\n"
488
+ " print(\" %s other: %.1f KiB\" % (len(other), size / 1024))\n"
489
+ " total = sum(stat.size for stat in top_stats)\n"
490
+ " print(\" Total allocated size: %.1f KiB\" % (total / 1024))\n"
491
+ "\n"
492
+ "tracemalloc.start()\n"
493
+ "\n"
494
+ "# ... 여러분의 응용 프로그램을 실행합니다 ...\n"
495
+ "\n"
496
+ "snapshot = tracemalloc.take_snapshot()\n"
497
+ "display_top(snapshot)"
352
498
353
499
#: ../../library/tracemalloc.rst:227
354
500
msgid ""
@@ -375,6 +521,28 @@ msgid ""
375
521
"6220 other: 3602.8 KiB\n"
376
522
"Total allocated size: 5303.1 KiB"
377
523
msgstr ""
524
+ "Top 10 lines\n"
525
+ "#1: Lib/base64.py:414: 419.8 KiB\n"
526
+ " _b85chars2 = [(a + b) for a in _b85chars for b in _b85chars]\n"
527
+ "#2: Lib/base64.py:306: 419.8 KiB\n"
528
+ " _a85chars2 = [(a + b) for a in _a85chars for b in _a85chars]\n"
529
+ "#3: collections/__init__.py:368: 293.6 KiB\n"
530
+ " exec(class_definition, namespace)\n"
531
+ "#4: Lib/abc.py:133: 115.2 KiB\n"
532
+ " cls = super().__new__(mcls, name, bases, namespace)\n"
533
+ "#5: unittest/case.py:574: 103.1 KiB\n"
534
+ " testMethod()\n"
535
+ "#6: Lib/linecache.py:127: 95.4 KiB\n"
536
+ " lines = fp.readlines()\n"
537
+ "#7: urllib/parse.py:476: 71.8 KiB\n"
538
+ " for a in _hexdig for b in _hexdig}\n"
539
+ "#8: <string>:5: 62.0 KiB\n"
540
+ "#9: Lib/_weakrefset.py:37: 60.0 KiB\n"
541
+ " self.data = set()\n"
542
+ "#10: Lib/base64.py:142: 59.8 KiB\n"
543
+ " _b32tab2 = [a + b for a in _b32tab for b in _b32tab]\n"
544
+ "6220 other: 3602.8 KiB\n"
545
+ "Total allocated size: 5303.1 KiB"
378
546
379
547
#: ../../library/tracemalloc.rst:253
380
548
msgid "Record the current and peak size of all traced memory blocks"
@@ -415,6 +583,24 @@ msgid ""
415
583
"print(f\" {first_size=}, {first_peak=}\" )\n"
416
584
"print(f\" {second_size=}, {second_peak=}\" )"
417
585
msgstr ""
586
+ "import tracemalloc\n"
587
+ "\n"
588
+ "tracemalloc.start()\n"
589
+ "\n"
590
+ "# 예제 코드: 커다란 임시 리스트로 합계를 계산합니다\n"
591
+ "large_sum = sum(list(range(100000)))\n"
592
+ "\n"
593
+ "first_size, first_peak = tracemalloc.get_traced_memory()\n"
594
+ "\n"
595
+ "tracemalloc.reset_peak()\n"
596
+ "\n"
597
+ "# 예제 코드: 작은 임시 리스트로 합계를 계산합니다\n"
598
+ "small_sum = sum(list(range(1000)))\n"
599
+ "\n"
600
+ "second_size, second_peak = tracemalloc.get_traced_memory()\n"
601
+ "\n"
602
+ "print(f\" {first_size=}, {first_peak=}\" )\n"
603
+ "print(f\" {second_size=}, {second_peak=}\" )"
418
604
419
605
#: ../../library/tracemalloc.rst:280 ../../library/tracemalloc.rst:759
420
606
msgid "Output::"
@@ -425,6 +611,8 @@ msgid ""
425
611
"first_size=664, first_peak=3592984\n"
426
612
"second_size=804, second_peak=29704"
427
613
msgstr ""
614
+ "first_size=664, first_peak=3592984\n"
615
+ "second_size=804, second_peak=29704"
428
616
429
617
#: ../../library/tracemalloc.rst:285
430
618
msgid ""
@@ -1121,7 +1309,6 @@ msgid "The :attr:`Traceback.total_nframe` attribute was added."
1121
1309
msgstr ":attr:`Traceback.total_nframe` 어트리뷰트가 추가되었습니다."
1122
1310
1123
1311
#: ../../library/tracemalloc.rst:743
1124
- #, fuzzy
1125
1312
msgid ""
1126
1313
"Format the traceback as a list of lines. Use the :mod:`linecache` module "
1127
1314
"to retrieve lines from the source code. If *limit* is set, format the "
@@ -1130,10 +1317,10 @@ msgid ""
1130
1317
"order of the formatted frames is reversed, returning the most recent "
1131
1318
"frame first instead of last."
1132
1319
msgstr ""
1133
- "줄 바꿈이 있는 줄의 리스트로 트레이스백을 포맷합니다. 소스 코드에서 줄을 꺼내는데 :mod:`linecache` 모듈을 "
1134
- "사용합니다. *limit*\\ 가 설정되면, *limit*\\ 가 양수일 때 가장 최신 *limit* 개의 프레임을 포맷합니다. 그렇지"
1135
- " 않으면, 가장 오래된 ``abs(limit)`` 개의 프레임을 포맷합니다. *most_recent_first*\\ 가 "
1136
- "``True`` \\ 이면, 포맷된 프레임의 순서가 반대로 되어, 가장 최근의 프레임을 마지막이 아니라 처음에 반환합니다."
1320
+ "줄의 리스트로 트레이스백을 포맷합니다. 소스 코드에서 줄을 꺼내는데 :mod:`linecache` 모듈을 사용합니다. "
1321
+ "*limit*\\ 가 설정되면, *limit*\\ 가 양수일 때 가장 최신 *limit* 개의 프레임을 포맷합니다. 그렇지 않으면, "
1322
+ "가장 오래된 ``abs(limit)`` 개의 프레임을 포맷합니다. *most_recent_first*\\ 가 ``True`` \\ 이면, "
1323
+ " 포맷된 프레임의 순서가 반대로 되어, 가장 최근의 프레임을 마지막이 아니라 처음에 반환합니다."
1137
1324
1138
1325
#: ../../library/tracemalloc.rst:750
1139
1326
msgid ""
@@ -1153,6 +1340,9 @@ msgid ""
1153
1340
"for line in traceback:\n"
1154
1341
" print(line)"
1155
1342
msgstr ""
1343
+ "print(\" Traceback (most recent call first):\" )\n"
1344
+ "for line in traceback:\n"
1345
+ " print(line)"
1156
1346
1157
1347
#: ../../library/tracemalloc.rst:761
1158
1348
msgid ""
@@ -1162,4 +1352,9 @@ msgid ""
1162
1352
" File \" test.py\" , line 12\n"
1163
1353
" tb = tracemalloc.get_object_traceback(f())"
1164
1354
msgstr ""
1355
+ "Traceback (most recent call first):\n"
1356
+ " File \" test.py\" , line 9\n"
1357
+ " obj = Object()\n"
1358
+ " File \" test.py\" , line 12\n"
1359
+ " tb = tracemalloc.get_object_traceback(f())"
1165
1360
0 commit comments