{"id":1000270,"date":"2024-12-27T09:48:34","date_gmt":"2024-12-27T01:48:34","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1000270.html"},"modified":"2024-12-27T09:48:36","modified_gmt":"2024-12-27T01:48:36","slug":"python%e5%a6%82%e4%bd%95%e8%bf%87%e5%8e%bbapp%e5%86%85%e5%ad%98","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1000270.html","title":{"rendered":"python\u5982\u4f55\u8fc7\u53bbapp\u5185\u5b58"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25074925\/d269db6d-c92a-4fcc-8d97-315e2f26a86f.webp\" alt=\"python\u5982\u4f55\u8fc7\u53bbapp\u5185\u5b58\" \/><\/p>\n<p><p> \u4e00\u3001PYTHON\u83b7\u53d6APP\u5185\u5b58\u7684\u5e38\u7528\u65b9\u6cd5  <\/p>\n<\/p>\n<p><p>\u8981\u5728Python\u4e2d\u83b7\u53d6\u5e94\u7528\u7a0b\u5e8f\u7684\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\uff0c\u53ef\u4ee5\u4f7f\u7528<strong>psutil\u5e93\u3001memory_profiler\u5e93\u3001tracemalloc\u6a21\u5757<\/strong>\u3002\u5176\u4e2d\uff0cpsutil\u5e93\u63d0\u4f9b\u4e86\u4e00\u4e2a\u8de8\u5e73\u53f0\u7684\u65b9\u6cd5\u6765\u83b7\u53d6\u7cfb\u7edf\u548c\u8fdb\u7a0b\u7684\u76f8\u5173\u4fe1\u606f\uff1bmemory_profiler\u5e93\u53ef\u4ee5\u901a\u8fc7\u5206\u6790\u4ee3\u7801\u7684\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u6765\u5e2e\u52a9\u4f18\u5316\u4ee3\u7801\uff1btracemalloc\u6a21\u5757\u53ef\u4ee5\u8ddf\u8e2aPython\u5185\u5b58\u7684\u5206\u914d\u60c5\u51b5\u3002<strong>psutil\u5e93\u662f\u6700\u5e38\u7528\u7684\u65b9\u6cd5\uff0c\u56e0\u4e3a\u5b83\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u7cfb\u7edf\u548c\u8fdb\u7a0b\u4fe1\u606f\u3002<\/strong><\/p>\n<\/p>\n<p><p><strong>psutil\u5e93<\/strong>\u53ef\u4ee5\u4f7f\u7528Process\u7c7b\u6765\u83b7\u53d6\u7279\u5b9a\u8fdb\u7a0b\u7684\u5185\u5b58\u4fe1\u606f\u3002\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u83b7\u53d6\u76ee\u6807\u5e94\u7528\u7a0b\u5e8f\u7684\u8fdb\u7a0bID\uff08PID\uff09\u3002\u53ef\u4ee5\u901a\u8fc7\u64cd\u4f5c\u7cfb\u7edf\u81ea\u5e26\u7684\u4efb\u52a1\u7ba1\u7406\u5668\u6216\u8005\u547d\u4ee4\u884c\u5de5\u5177\u6765\u83b7\u53d6PID\u3002\u7136\u540e\uff0c\u4f7f\u7528psutil\u5e93\u4e2d\u7684Process\u7c7b\uff0c\u901a\u8fc7PID\u83b7\u53d6\u8fdb\u7a0b\u5bf9\u8c61\uff0c\u8fdb\u800c\u8c03\u7528memory_info()\u65b9\u6cd5\u83b7\u53d6\u5185\u5b58\u4fe1\u606f\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import psutil<\/p>\n<p>pid = 1234  # \u66ff\u6362\u4e3a\u76ee\u6807\u5e94\u7528\u7a0b\u5e8f\u7684PID<\/p>\n<p>process = psutil.Process(pid)<\/p>\n<p>memory_info = process.memory_info()<\/p>\n<p>print(f&quot;RSS: {memory_info.rss \/ (1024  2)} MB&quot;)<\/p>\n<p>print(f&quot;VMS: {memory_info.vms \/ (1024  2)} MB&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e8c\u3001PSUTIL\u5e93\u8be6\u7ec6\u4ecb\u7ecd  <\/p>\n<\/p>\n<p><p><strong>psutil\u5e93<\/strong>\u662f\u4e00\u4e2a\u8de8\u5e73\u53f0\u7684Python\u5e93\uff0c\u63d0\u4f9b\u4e86\u4e00\u7ec4\u65b9\u6cd5\u6765\u8f7b\u677e\u83b7\u53d6\u7cfb\u7edf\u548c\u8fdb\u7a0b\u7684\u4fe1\u606f\u3002\u5b83\u652f\u6301Windows\u3001Linux\u3001macOS\u7b49\u591a\u79cd\u64cd\u4f5c\u7cfb\u7edf\uff0c\u5e76\u4e14\u53ef\u4ee5\u83b7\u53d6CPU\u3001\u5185\u5b58\u3001\u78c1\u76d8\u3001\u7f51\u7edc\u7b49\u591a\u65b9\u9762\u7684\u4fe1\u606f\u3002  <\/p>\n<\/p>\n<ol>\n<li><strong>\u5b89\u88c5\u4e0e\u57fa\u672c\u4f7f\u7528<\/strong><\/li>\n<\/ol>\n<p><p>\u8981\u4f7f\u7528psutil\u5e93\uff0c\u9996\u5148\u9700\u8981\u786e\u4fdd\u5df2\u7ecf\u5b89\u88c5\u3002\u53ef\u4ee5\u901a\u8fc7pip\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a  <\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install psutil<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u5bfc\u5165psutil\u6a21\u5757\u5e76\u8c03\u7528\u76f8\u5173\u65b9\u6cd5\u6765\u83b7\u53d6\u7cfb\u7edf\u548c\u8fdb\u7a0b\u7684\u4fe1\u606f\u3002  <\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import psutil<\/p>\n<h2><strong>\u83b7\u53d6\u7cfb\u7edfCPU\u4f7f\u7528\u7387<\/strong><\/h2>\n<p>cpu_usage = psutil.cpu_percent(interval=1)<\/p>\n<p>print(f&quot;CPU Usage: {cpu_usage}%&quot;)<\/p>\n<h2><strong>\u83b7\u53d6\u7cfb\u7edf\u5185\u5b58\u4f7f\u7528\u60c5\u51b5<\/strong><\/h2>\n<p>memory_info = psutil.virtual_memory()<\/p>\n<p>print(f&quot;Total Memory: {memory_info.total \/ (1024  3)} GB&quot;)<\/p>\n<p>print(f&quot;Av<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>lable Memory: {memory_info.available \/ (1024  3)} GB&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u83b7\u53d6\u8fdb\u7a0b\u5185\u5b58\u4f7f\u7528\u60c5\u51b5<\/strong><\/li>\n<\/ol>\n<p><p>psutil\u5e93\u63d0\u4f9b\u4e86Process\u7c7b\uff0c\u901a\u8fc7\u8be5\u7c7b\u53ef\u4ee5\u83b7\u53d6\u7279\u5b9a\u8fdb\u7a0b\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u5305\u62ec\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u3002  <\/p>\n<\/p>\n<p><pre><code class=\"language-python\">pid = 1234  # \u66ff\u6362\u4e3a\u76ee\u6807\u5e94\u7528\u7a0b\u5e8f\u7684PID<\/p>\n<p>process = psutil.Process(pid)<\/p>\n<h2><strong>\u83b7\u53d6\u5185\u5b58\u4fe1\u606f<\/strong><\/h2>\n<p>memory_info = process.memory_info()<\/p>\n<p>print(f&quot;RSS: {memory_info.rss \/ (1024  2)} MB&quot;)<\/p>\n<p>print(f&quot;VMS: {memory_info.vms \/ (1024  2)} MB&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><strong>RSS\uff08Resident Set Size\uff09<\/strong>\u8868\u793a\u8fdb\u7a0b\u5b9e\u9645\u4f7f\u7528\u7684\u7269\u7406\u5185\u5b58\u5927\u5c0f\uff0c\u800c<strong>VMS\uff08Virtual Memory Size\uff09<\/strong>\u8868\u793a\u8fdb\u7a0b\u5206\u914d\u7684\u865a\u62df\u5185\u5b58\u5927\u5c0f\u3002  <\/p>\n<\/p>\n<p><p>\u4e09\u3001MEMORY_PROFILER\u5e93\u7684\u4f7f\u7528  <\/p>\n<\/p>\n<p><p><strong>memory_profiler\u5e93<\/strong>\u4e13\u6ce8\u4e8e\u5206\u6790Python\u4ee3\u7801\u7684\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u8bc6\u522b\u4ee3\u7801\u4e2d\u7684\u5185\u5b58\u74f6\u9888\u3002  <\/p>\n<\/p>\n<ol>\n<li><strong>\u5b89\u88c5\u4e0e\u57fa\u672c\u4f7f\u7528<\/strong><\/li>\n<\/ol>\n<p><p>\u53ef\u4ee5\u901a\u8fc7pip\u547d\u4ee4\u5b89\u88c5memory_profiler\u5e93\uff1a  <\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install memory_profiler<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7<code>@profile<\/code>\u88c5\u9970\u5668\u5bf9\u7279\u5b9a\u51fd\u6570\u8fdb\u884c\u5185\u5b58\u5206\u6790\u3002  <\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from memory_profiler import profile<\/p>\n<p>@profile<\/p>\n<p>def my_function():<\/p>\n<p>    a = [1] * (10  6)<\/p>\n<p>    b = [2] * (2 * 10  7)<\/p>\n<p>    del b<\/p>\n<p>    return a<\/p>\n<p>my_function()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd0\u884c\u4ee3\u7801\u65f6\uff0c\u9700\u8981\u4f7f\u7528<code>-m memory_profiler<\/code>\u9009\u9879\uff1a  <\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python -m memory_profiler my_script.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u5206\u6790\u7ed3\u679c<\/strong><\/li>\n<\/ol>\n<p><p>memory_profiler\u5e93\u4f1a\u8f93\u51fa\u6bcf\u884c\u4ee3\u7801\u7684\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u5b9a\u4f4d\u5185\u5b58\u6d88\u8017\u8f83\u5927\u7684\u90e8\u5206\u3002\u901a\u8fc7\u5bf9\u6bd4\u4e0d\u540c\u7248\u672c\u7684\u4ee3\u7801\uff0c\u53ef\u4ee5\u6709\u6548\u4f18\u5316\u5185\u5b58\u4f7f\u7528\u3002  <\/p>\n<\/p>\n<p><p>\u56db\u3001TRACEMALLOC\u6a21\u5757\u7684\u4f7f\u7528  <\/p>\n<\/p>\n<p><p><strong>tracemalloc\u6a21\u5757<\/strong>\u662fPython\u5185\u7f6e\u7684\u5185\u5b58\u8ddf\u8e2a\u6a21\u5757\uff0c\u53ef\u4ee5\u8ddf\u8e2a\u5185\u5b58\u5206\u914d\u60c5\u51b5\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u8bc6\u522b\u5185\u5b58\u6cc4\u6f0f\u3002  <\/p>\n<\/p>\n<ol>\n<li><strong>\u57fa\u672c\u4f7f\u7528<\/strong><\/li>\n<\/ol>\n<p><p>\u53ef\u4ee5\u901a\u8fc7tracemalloc\u6a21\u5757\u6765\u542f\u52a8\u5185\u5b58\u8ddf\u8e2a\uff0c\u5e76\u83b7\u53d6\u5185\u5b58\u5feb\u7167\uff1a  <\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import tracemalloc<\/p>\n<h2><strong>\u542f\u52a8\u5185\u5b58\u8ddf\u8e2a<\/strong><\/h2>\n<p>tracemalloc.start()<\/p>\n<h2><strong>\u6267\u884c\u4ee3\u7801<\/strong><\/h2>\n<p>a = [1] * (10  6)<\/p>\n<p>b = [2] * (2 * 10  7)<\/p>\n<p>del b<\/p>\n<h2><strong>\u83b7\u53d6\u5185\u5b58\u5feb\u7167<\/strong><\/h2>\n<p>snapshot = tracemalloc.take_snapshot()<\/p>\n<h2><strong>\u6253\u5370\u5185\u5b58\u7edf\u8ba1\u4fe1\u606f<\/strong><\/h2>\n<p>for stat in snapshot.statistics(&#39;lineno&#39;):<\/p>\n<p>    print(stat)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u5206\u6790\u5185\u5b58\u6cc4\u6f0f<\/strong><\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u5bf9\u6bd4\u4e0d\u540c\u65f6\u95f4\u70b9\u7684\u5185\u5b58\u5feb\u7167\uff0c\u53ef\u4ee5\u8bc6\u522b\u5185\u5b58\u6cc4\u6f0f\u548c\u5185\u5b58\u589e\u957f\u60c5\u51b5\u3002tracemalloc\u6a21\u5757\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u7edf\u8ba1\u65b9\u6cd5\uff0c\u53ef\u4ee5\u6309\u4ee3\u7801\u884c\u3001\u6587\u4ef6\u3001\u51fd\u6570\u7b49\u8fdb\u884c\u5185\u5b58\u4f7f\u7528\u7edf\u8ba1\u3002  <\/p>\n<\/p>\n<p><p>\u4e94\u3001\u7ed3\u5408\u4f7f\u7528\u591a\u79cd\u5de5\u5177\u8fdb\u884c\u5185\u5b58\u5206\u6790  <\/p>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\uff0c\u53ef\u4ee5\u7ed3\u5408\u4f7f\u7528\u4e0a\u8ff0\u5de5\u5177\u8fdb\u884c\u5185\u5b58\u5206\u6790\u548c\u4f18\u5316\u3002psutil\u5e93\u53ef\u4ee5\u7528\u4e8e\u76d1\u63a7\u7cfb\u7edf\u548c\u8fdb\u7a0b\u7684\u6574\u4f53\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\uff0cmemory_profiler\u5e93\u53ef\u4ee5\u7528\u4e8e\u5206\u6790Python\u4ee3\u7801\u7684\u5185\u5b58\u6d88\u8017\uff0ctracemalloc\u6a21\u5757\u53ef\u4ee5\u7528\u4e8e\u8bc6\u522b\u5185\u5b58\u6cc4\u6f0f\u548c\u5185\u5b58\u589e\u957f\u3002\u901a\u8fc7\u591a\u79cd\u5de5\u5177\u7684\u7ed3\u5408\u4f7f\u7528\uff0c\u53ef\u4ee5\u66f4\u5168\u9762\u5730\u4e86\u89e3\u548c\u4f18\u5316\u5e94\u7528\u7a0b\u5e8f\u7684\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u3002  <\/p>\n<\/p>\n<ol>\n<li><strong>\u76d1\u63a7\u6574\u4f53\u5185\u5b58\u4f7f\u7528<\/strong><\/li>\n<\/ol>\n<p><p>\u4f7f\u7528psutil\u5e93\u76d1\u63a7\u7cfb\u7edf\u548c\u8fdb\u7a0b\u7684\u6574\u4f53\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\uff0c\u8bc6\u522b\u5185\u5b58\u4f7f\u7528\u7684\u5f02\u5e38\u60c5\u51b5\u3002  <\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import psutil<\/p>\n<h2><strong>\u83b7\u53d6\u7cfb\u7edf\u5185\u5b58\u4f7f\u7528\u60c5\u51b5<\/strong><\/h2>\n<p>memory_info = psutil.virtual_memory()<\/p>\n<p>print(f&quot;Total Memory: {memory_info.total \/ (1024  3)} GB&quot;)<\/p>\n<p>print(f&quot;Used Memory: {memory_info.used \/ (1024  3)} GB&quot;)<\/p>\n<h2><strong>\u83b7\u53d6\u7279\u5b9a\u8fdb\u7a0b\u7684\u5185\u5b58\u4f7f\u7528\u60c5\u51b5<\/strong><\/h2>\n<p>pid = 1234<\/p>\n<p>process = psutil.Process(pid)<\/p>\n<p>process_memory_info = process.memory_info()<\/p>\n<p>print(f&quot;Process RSS: {process_memory_info.rss \/ (1024  2)} MB&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u5206\u6790Python\u4ee3\u7801\u5185\u5b58\u4f7f\u7528<\/strong><\/li>\n<\/ol>\n<p><p>\u4f7f\u7528memory_profiler\u5e93\u5bf9\u5173\u952e\u51fd\u6570\u8fdb\u884c\u5185\u5b58\u5206\u6790\uff0c\u8bc6\u522b\u5185\u5b58\u6d88\u8017\u8f83\u5927\u7684\u90e8\u5206\u3002  <\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from memory_profiler import profile<\/p>\n<p>@profile<\/p>\n<p>def my_function():<\/p>\n<p>    a = [1] * (10  6)<\/p>\n<p>    b = [2] * (2 * 10  7)<\/p>\n<p>    del b<\/p>\n<p>    return a<\/p>\n<p>my_function()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li><strong>\u8ddf\u8e2a\u5185\u5b58\u5206\u914d\u548c\u6cc4\u6f0f<\/strong><\/li>\n<\/ol>\n<p><p>\u4f7f\u7528tracemalloc\u6a21\u5757\u8ddf\u8e2a\u5185\u5b58\u5206\u914d\u60c5\u51b5\uff0c\u8bc6\u522b\u5185\u5b58\u6cc4\u6f0f\u548c\u5185\u5b58\u589e\u957f\u3002  <\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import tracemalloc<\/p>\n<p>tracemalloc.start()<\/p>\n<h2><strong>\u6267\u884c\u4ee3\u7801<\/strong><\/h2>\n<p>a = [1] * (10  6)<\/p>\n<p>b = [2] * (2 * 10  7)<\/p>\n<p>del b<\/p>\n<p>snapshot = tracemalloc.take_snapshot()<\/p>\n<p>for stat in snapshot.statistics(&#39;lineno&#39;):<\/p>\n<p>    print(stat)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u7ed3\u5408\u4f7f\u7528\u8fd9\u4e9b\u5de5\u5177\uff0c\u53ef\u4ee5\u66f4\u5168\u9762\u5730\u4e86\u89e3\u5e94\u7528\u7a0b\u5e8f\u7684\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\uff0c\u8bc6\u522b\u5185\u5b58\u74f6\u9888\uff0c\u5e76\u91c7\u53d6\u76f8\u5e94\u7684\u4f18\u5316\u63aa\u65bd\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u4f7f\u7528Python\u76d1\u63a7\u5e94\u7528\u7a0b\u5e8f\u7684\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\uff1f<\/strong><br \/>\u4f7f\u7528Python\u76d1\u63a7\u5e94\u7528\u7a0b\u5e8f\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\uff0c\u53ef\u4ee5\u501f\u52a9\u4e00\u4e9b\u5e93\uff0c\u5982psutil\u548cmemory_profiler\u3002psutil\u63d0\u4f9b\u4e86\u83b7\u53d6\u7cfb\u7edf\u548c\u8fdb\u7a0b\u4fe1\u606f\u7684\u529f\u80fd\uff0c\u5305\u62ec\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u3002memory_profiler\u5219\u4e13\u6ce8\u4e8e\u76d1\u89c6Python\u4ee3\u7801\u7684\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u3002\u901a\u8fc7\u5728\u5173\u952e\u4ee3\u7801\u6bb5\u52a0\u4e0a\u88c5\u9970\u5668\uff0c\u53ef\u4ee5\u8f7b\u677e\u83b7\u53d6\u5185\u5b58\u4f7f\u7528\u6570\u636e\uff0c\u5e2e\u52a9\u5206\u6790\u6027\u80fd\u74f6\u9888\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5982\u4f55\u4f18\u5316\u5185\u5b58\u4f7f\u7528\u4ee5\u63d0\u9ad8\u5e94\u7528\u6027\u80fd\uff1f<\/strong><br \/>\u4f18\u5316\u5185\u5b58\u4f7f\u7528\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u5b9e\u73b0\u3002\u9996\u5148\uff0c\u51cf\u5c11\u4e0d\u5fc5\u8981\u7684\u5bf9\u8c61\u521b\u5efa\uff0c\u4f7f\u7528\u751f\u6210\u5668\u800c\u4e0d\u662f\u5217\u8868\u53ef\u663e\u8457\u964d\u4f4e\u5185\u5b58\u5360\u7528\u3002\u5176\u6b21\uff0c\u5408\u7406\u9009\u62e9\u6570\u636e\u7ed3\u6784\uff0c\u6bd4\u5982\u4f7f\u7528\u96c6\u5408\u800c\u975e\u5217\u8868\u6765\u63d0\u9ad8\u67e5\u627e\u6548\u7387\u3002\u6b64\u5916\uff0c\u5b9a\u671f\u4f7f\u7528\u5783\u573e\u56de\u6536\uff08gc\uff09\u6a21\u5757\uff0c\u6e05\u7406\u4e0d\u518d\u4f7f\u7528\u7684\u5bf9\u8c61\uff0c\u4e5f\u80fd\u5e2e\u52a9\u91ca\u653e\u5185\u5b58\uff0c\u63d0\u5347\u5e94\u7528\u6027\u80fd\u3002<\/p>\n<p><strong>Python\u4e2d\u6709\u54ea\u4e9b\u5de5\u5177\u53ef\u4ee5\u5e2e\u52a9\u5206\u6790\u5185\u5b58\u6cc4\u6f0f\u95ee\u9898\uff1f<\/strong><br \/>\u5206\u6790\u5185\u5b58\u6cc4\u6f0f\u95ee\u9898\u53ef\u4ee5\u4f7f\u7528\u591a\u79cd\u5de5\u5177\u3002objgraph\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5e93\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u53ef\u89c6\u5316\u5bf9\u8c61\u5f15\u7528\u5173\u7cfb\uff0c\u627e\u51fa\u672a\u88ab\u91ca\u653e\u7684\u5bf9\u8c61\u3002guppy\u662f\u53e6\u4e00\u4e2a\u5185\u5b58\u5206\u6790\u5de5\u5177\uff0c\u80fd\u591f\u63d0\u4f9b\u5185\u5b58\u4f7f\u7528\u7684\u8be6\u7ec6\u62a5\u544a\uff0c\u5e2e\u52a9\u8bc6\u522b\u6f5c\u5728\u7684\u5185\u5b58\u6cc4\u6f0f\u3002\u6b64\u5916\uff0c\u4f7f\u7528\u5185\u7f6e\u7684gc\u6a21\u5757\u53ef\u4ee5\u624b\u52a8\u89e6\u53d1\u5783\u573e\u56de\u6536\uff0c\u5e76\u67e5\u770b\u5f53\u524d\u53ef\u56de\u6536\u7684\u5bf9\u8c61\u6570\u91cf\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u4e00\u3001PYTHON\u83b7\u53d6APP\u5185\u5b58\u7684\u5e38\u7528\u65b9\u6cd5 \u8981\u5728Python\u4e2d\u83b7\u53d6\u5e94\u7528\u7a0b\u5e8f\u7684\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\uff0c\u53ef\u4ee5\u4f7f\u7528psutil\u5e93 [&hellip;]","protected":false},"author":3,"featured_media":1000279,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1000270"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1000270"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1000270\/revisions"}],"predecessor-version":[{"id":1000281,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1000270\/revisions\/1000281"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1000279"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1000270"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1000270"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1000270"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}