[英]OCaml Unix Error
I have run into an error that I am not sure how to debug. 我遇到了不确定如何调试的错误。 The error is
Exception: (Unix.Unix_error "Too many open files" pipe "")
. 错误是
Exception: (Unix.Unix_error "Too many open files" pipe "")
。 I am not opening any files and only have a single Unix process open. 我没有打开任何文件,只有一个Unix进程打开。 Anybody have some tips on how to debug this?
有人对如何调试它有一些提示吗?
The function causing the error is: 导致错误的函数是:
let rec update_act_odrs ?(sec_to_wait = 0.0) () =
try
(act_odrs := active_orders ())
|> fun _ -> Lwt_io.print "active_orders Updated\n"
with _ ->
Lwt_unix.sleep sec_to_wait
>>= update_act_odrs ~sec_to_wait:(sec_to_wait +. 1.0)
where active_orders ()
is a function that gets JSON data from a server. 其中
active_orders ()
是一个从服务器获取JSON数据的函数。
I would suggest to use ltrace
, to trace the calls to open
or pipe
function. 我建议使用
ltrace
,以跟踪对open
或pipe
函数的调用。 Also, it is good idea, just to grep your codebase, for functions that usually opens descriptors, eg openfile
, socket
, pipe
, popen
. 另外,最好是grep您的代码库,以用于通常打开描述符的函数,例如
openfile
, socket
, pipe
, popen
。
Also, you should know, that the failing function is not always a root of the evil. 另外,您应该知道,失败的功能并不总是邪恶的根源。 The descriptors can be eaten by some other process or function in your process.
描述符可能会被进程中的其他进程或函数吞噬。
You can also look at /proc
folder, if you're on linux, to make sure, that your process actually eats so many fd
s. 如果您使用的是Linux,还可以查看
/proc
文件夹,以确保您的进程实际上吃了很多fd
。 Maybe, you have another process in your system, that is launched by your application, and that is responsible for the fd leak. 也许您的系统中存在另一个进程,该进程由您的应用程序启动,并导致fd泄漏。
Finally, from the code you've shown, I can conclude, that the source of leak can be only active_orders
function. 最后,从您显示的代码中,我可以得出结论,泄漏源只能是
active_orders
函数。 If it downloads json
data from serve, it should open a socket connection. 如果它从serve下载
json
数据,则应打开套接字连接。 The fact that error message, points to the pipe is strange, maybe it is implemented with popen
or system
functions. 错误消息指向管道的事实很奇怪,也许是通过
popen
或system
功能实现的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.