[erlang-bugs] dets leaks open file descriptors

Håkan Mattsson <>
Thu Jan 30 14:15:54 CET 2014


dets:is_dets_file/1 leaks open file descriptors.

It is easy to reproduce. In the printout below you can
see that the number of open file descriptors grows for
each call to dets:is_dets_file/1.

/Håkan

#!/usr/bin/env escript
%% This is an -*- erlang -*- file.

main([Dir]) ->
     {ok, Files} = file:list_dir(Dir),
     Fun =
         fun(Fname0) ->
                 Fname = filename:join([Dir, Fname0]),
                 IsDetsFile = dets:is_dets_file(Fname) =:= true,
                 LsOf = os:cmd("lsof -p "++os:getpid()),
                 OpenFiles = string:tokens(LsOf, "\n"),
                 io:format("~p: ~p ~s\n", [length(OpenFiles), 
IsDetsFile, Fname])
         end,
     lists:foreach(Fun, Files),
     halt(0).

cd /usr/local/pgm/otp_R16B03-1/lib/erlang/lib/stdlib-1.19.4/src/
~/dets_files .
21: false ./dets.hrl
22: false ./erl_parse.yrl
23: false ./zip.erl
24: false ./win32reg.erl
25: false ./unicode.erl
26: false ./timer.erl
27: false ./sys.erl
28: false ./supervisor_bridge.erl
29: false ./supervisor.erl
30: false ./string.erl
31: false ./sofs.erl
32: false ./slave.erl
33: false ./shell_default.erl
34: false ./shell.erl
35: false ./sets.erl
36: false ./random.erl
37: false ./queue.erl
38: false ./qlc_pt.erl
39: false ./qlc.erl
40: false ./proplists.erl
41: false ./proc_lib.erl
42: false ./pool.erl
43: false ./re.erl
44: false ./pg.erl
45: false ./ordsets.erl
46: false ./orddict.erl
47: false ./otp_internal.erl
48: false ./ms_transform.erl
49: false ./math.erl
50: false ./log_mf_h.erl
51: false ./lists.erl
52: false ./lib.erl
53: false ./io_lib_pretty.erl
54: false ./io_lib_fread.erl
55: false ./io_lib_format.erl
56: false ./io_lib.erl
57: false ./io.erl
58: false ./gen_server.erl
59: false ./gen_fsm.erl
60: false ./gen_event.erl
61: false ./gen.erl
62: false ./gb_sets.erl
63: false ./gb_trees.erl
64: false ./filename.erl
65: false ./filelib.erl
66: false ./file_sorter.erl
67: false ./eval_bits.erl
68: false ./ets.erl
69: false ./escript.erl
70: false ./error_logger_tty_h.erl
71: false ./error_logger_file_h.erl
72: false ./erl_tar.erl
73: false ./erl_scan.erl
74: false ./erl_pp.erl
75: false ./erl_posix_msg.erl
76: false ./erl_parse.erl
77: false ./erl_lint.erl
78: false ./erl_internal.erl
79: false ./erl_expand_records.erl
80: false ./erl_eval.erl
81: false ./erl_compile.erl
82: false ./erl_bits.erl
83: false ./epp.erl
84: false ./edlin_expand.erl
85: false ./edlin.erl
86: false ./digraph_utils.erl
87: false ./digraph.erl
88: false ./dict.erl
89: false ./dets_v9.erl
90: false ./dets_v8.erl
91: false ./dets_utils.erl
92: false ./dets_sup.erl
93: false ./dets_server.erl
94: false ./dets.erl
95: false ./calendar.erl
96: false ./c.erl
97: false ./binary.erl
98: false ./beam_lib.erl
99: false ./base64.erl
100: false ./array.erl




More information about the erlang-bugs mailing list