A safer File.readln

Markus Laker via Digitalmars-d digitalmars-d at puremagic.com
Mon Jan 23 01:15:12 PST 2017


On Monday, 23 January 2017 at 01:55:59 UTC, Andrei Alexandrescu 
wrote:
> I recall reported size for special files is zero. We special 
> case std.file.read for those. -- Andrei

Special files are a bit of a distraction, in any case, because 
it's easy to create a large disk file full of zeroes:

msl at james:~/d$ dd if=/dev/zero of=zeroes count=2048 bs=1048576
2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB) copied, 11.1792 s, 192 MB/s
msl at james:~/d$ /usr/bin/time ./tinycat.d zeroes > /dev/null
1.67user 3.14system 0:04.83elapsed 99%CPU (0avgtext+0avgdata 
4199944maxresident)k
0inputs+0outputs (0major+1049634minor)pagefaults 0swaps
msl at james:~/d$

A 2GiB disk file caused tinycat.d to use over 4GiB of memory.

Cheers,

Markus



More information about the Digitalmars-d mailing list