file:read_file in R7B

Klacke <>
Thu Nov 16 14:32:47 CET 2000


On Thu, Nov 16, 2000 at 03:24:19PM +0100,  wrote:
> Miguel Barreiro Paz writes:
> 
>  > 	file:read_file/1 under R7B takes up an insane amount of memory,
>  > while it seemed to be far more reasonable in R6B. Is this a known
>  > bug? (or, probably, am I missing something?)
> 
> Can you be a bit more specific about the problem, e.g. how big is the
> file you're reading, how are you measuring memory, and what
> constitutes an "insane" amount?
> 
> One way which R7 differs from R6 is that many things involving
> binaries execute very slowly (and gobble memory) **in the shell**. For
> instance, doing
> 
>    {ok, Bin} = file:read_file("/usr/share/dict/words").
> 
> in the shell causes my beam emulator to jump to about 20Mb. Doing the
> same thing in a program, or even in different way in the shell:
> 
>    {ok, Bin} = file:read_file("/usr/share/dict/words"), z.
> 
> does not show unexpected memory consumption. 
> 
> Taking a guess, this is because the shell has an interpreter for
> binary operations.



It's because the shell keeps a histrory list of old
values. These values are accessible trough i.e v(-3) to get
3 values back. Thus the binary returned in 'Bin' above
is kept in the history list, and thus not freed for a while.

Killing the shell with exit() will make it drop the the history list.



/klacke


-- 
Claes Wikstrom                        -- Caps is nowhere and
Alteon WebSystems                     -- everything is under control          
http://www.bluetail.com/~klacke       --




More information about the erlang-questions mailing list