Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with ocamlc and big files #3430

Closed
vicuna opened this issue Jan 12, 2005 · 1 comment
Closed

problem with ocamlc and big files #3430

vicuna opened this issue Jan 12, 2005 · 1 comment
Labels

Comments

@vicuna
Copy link

vicuna commented Jan 12, 2005

Original bug ID: 3430
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

hi,
i have a program to count lines. this works well, when compiled with ocamlopt
but it does not work on big files (more than 60000 lines) when compiled with
ocamlc.

program is:

########
let stream_fold_lines handler inival strm =
let rec reader res =
try reader (handler (input_line strm) res)
with | End_of_file -> res
in reader inival

let file_fold_lines handler inival filename =
try
let strm = open_in filename in
let res = stream_fold_lines handler inival strm in
close_in strm; res
with _ -> inival

let count_lines fname = file_fold_lines (fun ln (_,cnt) -> (ln,cnt + 1))
("",1) fname

let main () = let fna = Sys.argv.(1) in let (ln,cnt) = count_lines fna in
Printf.printf "%s: lines %10d last <%s>\n" fna cnt ln

let _ = main ()

#################

operating system is:  SuSe Linux 9.0


ocaml version is:

ocamlc -version
3.08.2

Output:

wc -l b65536.txt
52429 b65536.txt

ocamlc tt.ml
./a.out b65536.txt
b65536.txt: lines 1 last <>

ocamlopt tt.ml
./a.out b65536.txt
b65536.txt: lines 52430 last <0000052429|
ovcjqxelszgnubipwdkryfmtahovcjqxelszgnubipwdkryfmtahovcjqxelszgnubip>

m.becker

@vicuna
Copy link
Author

vicuna commented Jan 13, 2005

Comment author: administrator

Hi,

Your program fails with `stack overflow' on big files when compiled
with ocamlc, and the corresponding exception is trapped with
" _ -> inival" in your file_fold_lines function.

-- Michel

Michael.Becker@coconet.de wrote/écrivait (Wed, Jan 12, 2005 at 09:06:37PM +0100):

hi,
i have a program to count lines. this works well, when compiled with ocamlopt
but it does not work on big files (more than 60000 lines) when compiled with
ocamlc.

program is:

########
let stream_fold_lines handler inival strm =
let rec reader res =
try reader (handler (input_line strm) res)
with | End_of_file -> res
in reader inival

let file_fold_lines handler inival filename =
try
let strm = open_in filename in
let res = stream_fold_lines handler inival strm in
close_in strm; res
with _ -> inival

let count_lines fname = file_fold_lines (fun ln (_,cnt) -> (ln,cnt + 1))
("",1) fname

let main () = let fna = Sys.argv.(1) in let (ln,cnt) = count_lines fna in
Printf.printf "%s: lines %10d last <%s>\n" fna cnt ln

let _ = main ()

#################

operating system is: SuSe Linux 9.0

ocaml version is:

ocamlc -version
3.08.2

Output:

wc -l b65536.txt
52429 b65536.txt

ocamlc tt.ml
./a.out b65536.txt
b65536.txt: lines 1 last <>

ocamlopt tt.ml
./a.out b65536.txt
b65536.txt: lines 52430 last <0000052429|
ovcjqxelszgnubipwdkryfmtahovcjqxelszgnubipwdkryfmtahovcjqxelszgnubip>

m.becker


Caml-devel mailing list
Caml-devel@yquem.inria.fr
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-devel

--

@vicuna vicuna closed this as completed Jan 18, 2005
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant