[英]Understanding anomalous memory usage by python 3.7
我在 macbook pro 上使用 OSX 10.13.6 並從 home brew 運行 Python 3.7.6。 當我從命令行運行python
,它需要幾分鍾才能啟動。 最終啟動后,我查看任務管理器,它使用了約 11GB 的壓縮內存。 我沒有運行任何程序或加載任何庫,我只是在啟動 python 解釋器。
當我在 CentOS 7 機器上運行 python 3.7 時,它使用的是 8MB。
世界正在發生什么? 為什么python
在我的mac上使用這么多內存? 它並不總是這樣,如果我沒有記錯的話,我想我最近(在過去 6 個月內)不得不從自制軟件重新安裝 python。
我使用~/.pystartup
保存我的python
歷史記錄。 我有
historyPath = "/Users/user/.pyhistory"
def save_history(historyPath=historyPath):
import readline
readline.write_history_file(historyPath)
if os.path.exists(historyPath):
print("Reading python history ... {}".format)
readline.read_history_file(historyPath)
atexit.register(save_history)
del os, atexit, readline, rlcompleter, save_history, historyPath
在某些時候,我一定不小心在python
解釋器中粘貼了一個大文件。 我的~/.pyhistory
文件大小為 1.6GB,有 146322287 行。 刪除它,解決了我的問題, python
又回到在我的 mac 上使用 MB 了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.