Do you want to know why there is a leak, or why linux is able to free memor=
y
!?
If you want to know where your code is wrong :
I will not tell you what is the problem, but I think following stuff will
help you :
Did you tried your stuff on your host system before ?
just an idea : Try looking how you open/close your files .. (and test your
FILE* before any read/write !!! if you don't like that, play with C++)
PS : I love waiting for 60 seconds to see the problem :)
2005/10/3, Terje.Utheim@... <Terje.Utheim@... >:
>
> This sequence is allocating (leaking) memory on the gumstix bit by bit
> until
> process is killed. Memory returned when aborted. What is wrong ?
>
> #include <stdlib.h>
> #include <unistd.h>
> #include <stdio.h>
> #include <sys/types.h>
> #include <fcntl.h>
> #include <string.h>
> #include <errno.h>
> #include <sys/stat.h>
> main()
> {
> int i;
> unsigned char blk[4096];
> FILE *rng;
> for(i=3D0;i<4096;i++)
> blk[i]=3Di;
> rng=3Dfopen("/mnt/cf/slg/rng/test0","w+");
> if(rng =3D=3D NULL)
> {
> exit(0);
> }
> for(;;)
> {
> for(i=3D0;i<60;i++)
> {
> printf("%3d\n",i);
> fwrite(&blk,4096, 1, rng);
> fflush(rng);
> sleep(1);
> }
> fclose(rng);
>
> rng=3Dfopen("/mnt/cf/slg/rng/test1","w+");
>
> if(rng =3D=3D NULL)
> {
> exit(0);
> }
> for(i=3D0;i<60;i++)
> {
> printf("%3d\n",i);
> fwrite(&blk,4096, 1, rng);
> fflush(rng);
> sleep(1);
> }
> fclose(rng);
> }
> }
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by:
> Power Architecture Resource Center: Free content, downloads, discussions,
> and more. http://solutions.newsforge.com/ibmarch.tmpl
> _______________________________________________
> gumstix-users mailing list
> gumstix-users@...
> https://lists.sourceforge.net/lists/listinfo/gumstix-users
>
--
J=E9r=F4me Multrier
TinyCoach, un projet KaliBee
|