prompt-toolkit / ptpython

A better Python REPL
BSD 3-Clause "New" or "Revised" License
5.23k stars 281 forks source link

Pager has exceptionally bad memory usage and performance displaying long bytestrings #560

Closed tapple closed 8 months ago

tapple commented 11 months ago

Run this command to make ptpython pager eat up all the memory and eventually (after 43m 49s for me) get killed for memory pressure:

06:39:14$ PS1='\T\$ '
06:39:24$ ptpython
>>> content = b'\x90' * 40_000_000
>>> content

Message from syslogd@vubuntu at Dec  7 18:40:14 ...
 kernel:[63403.334250] watchdog: BUG: soft lockup - CPU#1 stuck for 38s! [swapper/1:0]
Killed
07:23:13$ 
07:58:06$ ptpython --version
3.0.23
07:58:16$ python --version
Python 3.9.18

I ran this on a linux vm with 4gm ram and 2gb swap

I don't know if the cpu lockup warning is related, but I left it in for completeness. It appeared 4 out of 5 times I tried running this code on ptpython on this vm. I only waited one of those times to see how long it took linux to kill ptpython. the other 4 times I killed it manually (SIGTERM) from htop

jonathanslenders commented 8 months ago

This was fixed here: https://github.com/prompt-toolkit/ptpython/pull/562