help-flex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory Leak


From: John Millaway
Subject: Re: Memory Leak
Date: Fri, 21 Jun 2002 15:30:27 -0700 (PDT)

> Memory leak - 16386 bytes allocated by maloc
>
> Function yy_flex_alloc()

Yeah, we know about that one already ;)  Actually, the leak is ~16426 bytes.
That is, (8192 * 2 + 2) for the read-buffer, and about 40 for struct
yy_buffer_state.  The leak is in the non-reentrant C scanner only (NOT in the
reentrant scanner, NOT in the C++ scanner).

Since flex doesn't know when you are done, the buffer is never freed. However,
the leak won't multiply since the buffer is reused no matter how many times you
call yylex(). If you want to reclaim the memory when you are completely done
scanning, then you might try this: 
 
    /* For non-reentrant C scanner only. */ 
    yy_delete_buffer(yy_current_buffer);
    yy_init = 1;

Note: yy_init is an "internal variable", and hasn't been tested in this
situation. It is possible that some other globals may need resetting as well.

-John


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com



reply via email to

[Prev in Thread] Current Thread [Next in Thread]