Re: Non-paged pool memory leak in when huge number of files is created

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



It's most likely not a memory leak. Usually file systems do not delete immediately at the file closing process the internal data structures which have been created for support of work with the opened files. Counting upon that the same files will be open again in the near future.

--
Best regards,
Vladimir Zinin
mailto:vzinin@xxxxxxxxx


Jasen Kolev wrote:
We have found a problem in XP SP2 witch is concludes in huge non-paged memory leak, when process creates huge number in files. Process is a program that works as a “black-box” and writes small amount of data in different files similar to next simple code written in C:
/*--------------------------------------------------------
//Program 10 times creates 10000 files 4KB each //Each time deletes previously created 10000 files
// last 10000 files are left in dir
*/

#include <stdio.h>

char buf[4096];
void main(void)
{
FILE *f;
char filename[80];
int i,j;
for ( j=0; j<10 ;j++){
for(i=0;i<10000;i++){
sprintf(filename,"c:\\temp\\t%02d-%06d.bin",j,i);
f=fopen(filename,"w+b");
fwrite(buf,sizeof(char),4096,f);
fflush(f);
fclose(f);
}
if (0!=j)
for(i=0;i<10000;i++){
sprintf(filename,"c:\\temp\\t%02d-%06d.bin",j-1,i);
remove(filename);
}
}
}
/*----------------------------------------------*/
We try this with several different VC6, VC2003,VC2005 also in C# and similar program using pure Windows API, same efect. We also run this program on different hrdware configurations.

.



Relevant Pages

  • Re: Allocating memory for struct - when?
    ... > believe it is because there's some memory leak - the debugger tells me ... instead of "char". ... how would the compiler know how much memory to ... example of a situation that flexible array members were designed for. ...
    (comp.lang.c)
  • Re: xmalloc string functions
    ... char *foo, *bar; ... will quit and a memory leak will occur because the return ... value of dup() was not freed */ ...
    (comp.lang.c)
  • Re: pointers and strings
    ... The only correct and defined way to print the value of a pointer to ... > char *p; ... you would be creating a memory leak because you would be throwing away ... have an appropriate newsgroups line in your header for your mail to be seen, ...
    (comp.lang.c.moderated)
  • Re: stl string and win32 API
    ... The difference between using a vector and manually allocating a char* ... is that vector will automatically free its memory when it goes ... whereas you have to remember to free the array. ... chance of introducing a memory leak. ...
    (microsoft.public.vc.stl)