Re: [uCsimm] Memory leak caused by fopen

From: David Beckemeyer (david@bdt.com)
Date: Tue Jun 05 2001 - 17:17:57 EDT


Yes, it's some mmap() problem that I never fully resolved. I
posted a uClibc patch for simple-malloc to work-around it. The
patch is for the 'old' uClibc (the one that ships with uCsimm)
not the 'new' one (which must be buil with the elf toolchain).

Search the archives for a message with the subject:

    uC-libc malloc-simple memory leak patch

Let me know if you don't find it.

On Tue, Jun 05, 2001 at 09:05:30PM +0100, Ian Leonard wrote:
>
> I have a program with a memory leak. Every 4 or 5 iterations, memory
> usage goes up by 4096 bytes. Does anybody know why this should be?
>
> I see from the uClib source that fopen allocates a buffer for the
> data when it opens. I thought that this should be done on the first
> i/o operation. It looks like fclose deallocates memory (although it
> obviously doesn't) and setvbuf () doesn't help either.
>
> Thanks.
>
> int
> main ()
> {
> FILE *fp;
>
> while ( 1) {
>
> if ( ( fp = fopen ( DATAFILE, "w")) == NULL) {
> perror ( DATAFILE);
> return 1;
> }
>
> fclose ( fp);
> }
> }
>
>
> --
> Ian Leonard
> eMail: ileonard@ntlworld.com
> Phone: +44 (0)1865 765273 Fax: +44 (0)1865 765280
>
> Please ignore spelling and punctuation - I did.
> This message resent by the ucsimm@uclinux.com list server http://www.uClinux.com/
This message resent by the ucsimm@uclinux.com list server http://www.uClinux.com/



This archive was generated by hypermail 2b30 : Sun Apr 07 2002 - 00:01:43 EST