Skip to content

Commit

Permalink
Fix win32 memory leak by using raw file operations. Not ideal but this
Browse files Browse the repository at this point in the history
skips all file servers.
  • Loading branch information
lukebakken committed Dec 17, 2021
1 parent 249e8c8 commit a0a8b59
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions deps/rabbit/src/rabbit_file.erl
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,19 @@ read_file_info(File) ->

read_term_file(File) ->
try
{ok, Data} = with_handle(fun () -> prim_file:read_file(File) end),
{ok, Tokens, _} = erl_scan:string(binary_to_list(Data)),
TokenGroups = group_tokens(Tokens),
{ok, [begin
{ok, Term} = erl_parse:parse_term(Tokens1),
Term
end || Tokens1 <- TokenGroups]}
{ok, FInfo} = file:read_file_info(File, [raw]),
{ok, Fd} = file:open(File, [read, raw, binary]),
try
{ok, Data} = file:read(Fd, FInfo#file_info.size),
{ok, Tokens, _} = erl_scan:string(binary_to_list(Data)),
TokenGroups = group_tokens(Tokens),
{ok, [begin
{ok, Term} = erl_parse:parse_term(Tokens1),
Term
end || Tokens1 <- TokenGroups]}
after
ok = file:close(Fd)
end
catch
error:{badmatch, Error} -> Error
end.
Expand Down

0 comments on commit a0a8b59

Please sign in to comment.