我是一名有用的助手,可以为您进行文本翻译。以下是需要翻译的内容:
使用这种方法,我的系统上的线程总数为75,远远低于961的限制。以下是我的当前内存状态:
我有一个嵌入式系统(armv5tejl AT91SAM9X25,带有128MB RAM,运行基于buildroot的rootfs),安装了Python 3。我已经让这个系统运行了很多天,现在我想在上面进行一些Python开发工作,但好像在创建新线程时遇到了问题。
如果我尝试运行以下程序:
Type "help", "copyright", "credits" or "license" for more information.
>>> import threading
>>> import time
>>> def func():
... i = 0
... while True:
... i += 1
... print(i)
... time.sleep(1)
...
>>>
>>> func()
1
2
3
^CTraceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 6, in func
KeyboardInterrupt
>>> t = threading.Thread(target=func)
>>> t.start()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.4/threading.py", line 850, in start
RuntimeError: can't start new thread
>>>
正如您所见,当尝试启动线程时,我收到了上述错误。在网上进行一些初步搜索似乎表明,问题可能是由于系统遇到线程限制引起的。以下是ulimit -a的输出:
# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 961
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 961
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
使用这种方法,我的系统上的线程总数为75,远远低于961的限制。以下是我的当前内存状态:
# free -m
total used free shared buffers cached
Mem: 120 118 2 60 0 65
-/+ buffers/cache: 52 67
Swap: 0 0 0
我还通过运行echo 1 > /proc/sys/vm/compact_memory
来运行内存压缩器。
我想如果我重新启动设备,一切都会正常工作(因为代码是已知的可行代码),但由于我现在有设备处于这种状态,所以我很想尝试理解问题出在哪里。