@@ -17,9 +17,8 @@ msgstr ""
1717"Generated-By : Babel 2.17.0\n "
1818
1919#: ../../library/tracemalloc.rst:2
20- #, fuzzy
2120msgid ":mod:`!tracemalloc` --- Trace memory allocations"
22- msgstr ":mod:`tracemalloc` --- 메모리 할당 추적"
21+ msgstr ":mod:`! tracemalloc` --- 메모리 할당 추적"
2322
2423#: ../../library/tracemalloc.rst:9
2524msgid "**Source code:** :source:`Lib/tracemalloc.py`"
@@ -95,6 +94,18 @@ msgid ""
9594"for stat in top_stats[:10]:\n"
9695" print(stat)"
9796msgstr ""
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)"
98109
99110#: ../../library/tracemalloc.rst:55 ../../library/tracemalloc.rst:225
100111msgid "Example of output of the Python test suite::"
@@ -122,6 +133,25 @@ msgid ""
122133"/usr/lib/python3.4/sysconfig.py:411: size=48.0 KiB, count=1, average=48.0"
123134" KiB"
124135msgstr ""
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"
125155
126156#: ../../library/tracemalloc.rst:69
127157msgid ""
@@ -161,6 +191,19 @@ msgid ""
161191"for stat in top_stats[:10]:\n"
162192" print(stat)"
163193msgstr ""
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)"
164207
165208#: ../../library/tracemalloc.rst:95
166209msgid ""
@@ -192,6 +235,27 @@ msgid ""
192235"/usr/lib/python3.4/contextlib.py:38: size=67.2 KiB (+67.2 KiB), count=126"
193236" (+126), average=546 B"
194237msgstr ""
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"
195259
196260#: ../../library/tracemalloc.rst:109
197261msgid ""
@@ -242,6 +306,21 @@ msgid ""
242306"for line in stat.traceback.format():\n"
243307" print(line)"
244308msgstr ""
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)"
245324
246325#: ../../library/tracemalloc.rst:141
247326msgid ""
@@ -286,6 +365,40 @@ msgid ""
286365" File \" /usr/lib/python3.4/runpy.py\" , line 160\n"
287366" \" __main__\" , fname, loader, pkg_name)"
288367msgstr ""
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)"
289402
290403#: ../../library/tracemalloc.rst:178
291404msgid ""
@@ -349,6 +462,39 @@ msgid ""
349462"snapshot = tracemalloc.take_snapshot()\n"
350463"display_top(snapshot)"
351464msgstr ""
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)"
352498
353499#: ../../library/tracemalloc.rst:227
354500msgid ""
@@ -375,6 +521,28 @@ msgid ""
375521"6220 other: 3602.8 KiB\n"
376522"Total allocated size: 5303.1 KiB"
377523msgstr ""
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"
378546
379547#: ../../library/tracemalloc.rst:253
380548msgid "Record the current and peak size of all traced memory blocks"
@@ -415,6 +583,24 @@ msgid ""
415583"print(f\" {first_size=}, {first_peak=}\" )\n"
416584"print(f\" {second_size=}, {second_peak=}\" )"
417585msgstr ""
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=}\" )"
418604
419605#: ../../library/tracemalloc.rst:280 ../../library/tracemalloc.rst:759
420606msgid "Output::"
@@ -425,6 +611,8 @@ msgid ""
425611"first_size=664, first_peak=3592984\n"
426612"second_size=804, second_peak=29704"
427613msgstr ""
614+ "first_size=664, first_peak=3592984\n"
615+ "second_size=804, second_peak=29704"
428616
429617#: ../../library/tracemalloc.rst:285
430618msgid ""
@@ -1121,7 +1309,6 @@ msgid "The :attr:`Traceback.total_nframe` attribute was added."
11211309msgstr ":attr:`Traceback.total_nframe` 어트리뷰트가 추가되었습니다."
11221310
11231311#: ../../library/tracemalloc.rst:743
1124- #, fuzzy
11251312msgid ""
11261313"Format the traceback as a list of lines. Use the :mod:`linecache` module "
11271314"to retrieve lines from the source code. If *limit* is set, format the "
@@ -1130,10 +1317,10 @@ msgid ""
11301317"order of the formatted frames is reversed, returning the most recent "
11311318"frame first instead of last."
11321319msgstr ""
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+ " 포맷된 프레임의 순서가 반대로 되어, 가장 최근의 프레임을 마지막이 아니라 처음에 반환합니다."
11371324
11381325#: ../../library/tracemalloc.rst:750
11391326msgid ""
@@ -1153,6 +1340,9 @@ msgid ""
11531340"for line in traceback:\n"
11541341" print(line)"
11551342msgstr ""
1343+ "print(\" Traceback (most recent call first):\" )\n"
1344+ "for line in traceback:\n"
1345+ " print(line)"
11561346
11571347#: ../../library/tracemalloc.rst:761
11581348msgid ""
@@ -1162,4 +1352,9 @@ msgid ""
11621352" File \" test.py\" , line 12\n"
11631353" tb = tracemalloc.get_object_traceback(f())"
11641354msgstr ""
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())"
11651360
0 commit comments