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

Re: Bug Report?! Part II.



Hi,

first, i dont like to comment on the answers i got.
(especially because of the undertone that implied that
i'm not working thoroughly). if i hadn't checked my program
for possible memory-leaks i'd never dared raising that
issue here on "DEVEL".

i'd like to make a proposal instead, before answering
again, just put my claims to the test. 

how?

quite easy!

just write two small programs and let it run.

if you've done that, report your findings wheather they 
supply my statements or not and then we'll discuss the whole
matter again, this time based on facts - not assumptions.

outlines for test-programms:

1. Create a (huge) test-input file

// record layout
struct InRec {
  long Values[1000];
}

struct InRec FileRec;
FILE *New_One;

int main() {
  long Total_File_Size, Min_File_Size;
  int I, Len;
  New_One = fopen("???.inp", "w");
  Len = sizeof(struct InRec);	
  Total_File_Size = 0;
  Min_File_Size = 20000000; /* fill in a size shure to overload
    your available memory */
  while (Total_File_Size < Min_File_Size) {
    for (I = 0; I < 1000; I++) FileRec.Values[I] = random();  
    fwrite(&FileRec, Len, 1, New_One);
    Total_File_Size += Len;
  }
  fclose (New_One);
  return 0;
}

2. the Test-Program

// record layout
struct InRec {
  long Values[1000];
}

struct VarRec {
  long Change[100];
} 

struct InRec FileRec; 
struct VarRec Update, Init_Rec;
FILE *Input, *Var;

int main() {
  int I, J, Level, MaxLevel, , Len_In, Len_Var;
  long Pos;
  MaxLevel = ??; /* make shure to select a number
    big enough you have something to observe. */
  Len_In = sizeof(struct InRec);
  Len_Var = sizeof(struct VarRec);
  Input = fopen("???.inp", "r");
  Var = fopen("???.var", "w+");
  for (Level = 0; Level < MaxLevel; Level++) {
    fseek (Input, 0, SEEK_SET);
    fseek (Var, 0, SEEK_SET);
    for (I = 0; I < 1000; I++) 
      fwrite(&Init_Rec, Var_Len, 1, Var);
    while (fread(&FileRec, Len_In, 1, Input)) {
      for (I = 0; I < 1000; I++) {
        Pos = I; 
        Pos *= Len_Var;
        fseek(Var, Pos, SEEK_SET);
        fread(&Update, Var_Len, 1, Var);
        for (J = 0; J < 99; J++)
          Update.Change[J] = Update.Change[J + 1];
        Update.Change[99] = File_Rec.Values[I]; 
        fseek(Var, Pos, SEEK_SET);
        fwrite(&Update, Var_Len, 1, Var);
      } 
    }
  }
  fclose(Input);
  fclose(Var);
  return 0;	
}

Helmut Metzdorf


Reply to: