Autor Beitrag
galagher
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2562
Erhaltene Danke: 46

Windows 10 Home
Delphi 10.1 Starter, Lazarus 2.0.6
BeitragVerfasst: So 30.05.04 21:09 
Hallo!

Sowas hab ich ja noch nie gesehen: Mein Programm ruft rekursiv eine Funktion auf (sucht Files in allen Ordnern) und vergleicht die Grösse, Datum, Zeit und Attribute mit den Werten, die es zuvor irgendwann in einer Datei gespeichert hat. Das geht auch ganz gut, es prüft ca. 1600 Dateien und schreibt deren Namen, Pfad usw. in ein StringGrid, aber dann wird es immer langsamer.

Also habe ich GlobalMemoryStatus eingebaut, um den freien Speicher zu sehen - der bleibt zunächst konstant und fällt urplötzlich auf 0 ab - und dann steht Windows, und die Maus ist wie festgeklebt! In einer Minute schafft mein Proggi dann grad mal 1 Datei. Es tut weiter, eben extrem langsam.

Ich vergesse nicht, irgendwas freizugeben, alles schon überprüft. Egal, ob mit ins StringGrid schreiben oder ohne, es ist immer dasselbe, immer bei ca. 1600 Dateien. Danach bleibt Windows auch langsam, bis zum Neustart.

Ich meine, wenn ich Speicher verbrauche, dann doch wohl von Anfang an, also vom 1. Aufruf der Funktion, nicht erst mitten drin! Kann mir jemand einen Tip geben, was das sein kann? Sonst kann ich das Projekt vergessen! Danke euch!!!

_________________
gedunstig war's - und fahle wornen zerschellten karsig im gestrock. oh graus, es gloomt der jabberwock - und die graisligen gulpen nurmen!
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: So 30.05.04 21:32 
Ist es möglich, dass zu diesem Zeitpunkt ein Verzeichnis mit extrem vielen Dateien oder Unterverzeichnissen erreicht wird und deswegen schlagartig soviel Speicher verbraucht wird?

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
galagher Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2562
Erhaltene Danke: 46

Windows 10 Home
Delphi 10.1 Starter, Lazarus 2.0.6
BeitragVerfasst: Mo 31.05.04 07:30 
Peter Lustig hat folgendes geschrieben:
Ist es möglich, dass zu diesem Zeitpunkt ein Verzeichnis mit extrem vielen Dateien oder Unterverzeichnissen erreicht wird und deswegen schlagartig soviel Speicher verbraucht wird?


Danke für die rasche Antwort! Hab's beobachtet: der Speicher begann sich im System-Ordner zu verringern, lief aber alles normal. Danach fiel er wieder total ab. Wenn ich nicht abgebrochen hätte, wäre es wieder 0 geworden. Was kann man da tun?

_________________
gedunstig war's - und fahle wornen zerschellten karsig im gestrock. oh graus, es gloomt der jabberwock - und die graisligen gulpen nurmen!
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: Mo 31.05.04 08:20 
kannst du mal etwas code zeigen ?
grez
msch

_________________
ist das politisch, wenn ich linksdrehenden Joghurt haben möchte?
galagher Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2562
Erhaltene Danke: 46

Windows 10 Home
Delphi 10.1 Starter, Lazarus 2.0.6
BeitragVerfasst: Mo 31.05.04 08:32 
MSCH hat folgendes geschrieben:
kannst du mal etwas code zeigen ?


Nachdem ich echt keine Ahnung habe, WAS das Problem verursacht, poste ich am Besten die gesamte Prozedur (hab' vorhin in der Eile Funktion geschrieben).

Wenn ihr euch da durchwühlt... Das Prinzip: Suche nach Dateien, feststellen von Grösse, Attribut un Datum/Zeit, feststellen, ob Sonderzeichen (ausser ä,ö,ü,ß usw.) im Namen. Vergleichen der aktuellen Werte mit zuvor gespeicherten, bei Abweichungen "GEÄND." in StringGrid1 ausgeben, sonst "OK", bei Fehler "XXXXX". Jeder Ordner enthält eine Datei chklist.fst.

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405:
406:
407:
408:
409:
410:
411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:
428:
429:
procedure TForm1.FindExecutableFiles(Path, Mask: String; List: TStrings; SubFolder: Boolean);
var
  I, Attr, k: Integer;
  Search: TSearchRec;
  chklist: Boolean;
  S, OldSize, NewSize: String;
begin
caption:=inttostr(MemoryStatus(3));//++

  Attr := faArchive + faReadOnly + faHidden + faSysFile;
  Path := IncludeTrailingPathDelimiter(Path);
  P := Path;
  Fail := False;

  Application.ProcessMessages;

  if Stop then
  begin
   SysUtils.FindClose(Search);
   exit;
  end;

  with TStringList.Create do
  try
   CommaText := Mask;
   chklist := not (FileExists(Path+ChkFile));

   if not chklist then
   begin
   try
    List2.LoadFromFile(Path+ChkFile);
    List2.Text := ShiftStr(List2.Text,-85);
    Inc(ChkFileCount);  {Zählen, wenn ChkFile-Datei existiert,}
        {falls aber die einzige Datei in der ChkFile-Datei ...}
    if (List2.Count <= 2) and (List2[1] = '¸µ') then
     if not FileExists(GetWord(List2[0],1)) then
    begin   {... nicht (mehr) existiert (gelöscht worden etc),}
     EraseFile(Path+ChkFile);  {dann die ChkFile-Datei löschen}
     Dec(ChkFileCount);    {und 1 ChkFile-Datei weniger zählen}
    end;
    except
     SysUtils.FindClose(Search);
    end;

    List2.Clear;
   end;

   SetFileAttr(Path+ChkFile, '-r-h-s+a');

   for k := 0 to Count - 1 do
   if FindFirst(Path + Strings[k], Attr, Search) = 0 then
    repeat  {Prüfen, ob Sonderzeichen im Dateinamen vorkommen, ...}
      for I := 1 to Length(Search.Name) do
       if ((Ord(Search.Name[I]) < 33) or
          (Ord(Search.Name[I]) > 126)) and not
 {Leerz.} (Ord(Search.Name[I]) = 32) and not
      {Ä} (Ord(Search.Name[I]) = 196) and not
      {Ö} (Ord(Search.Name[I]) = 214) and not
      {Ü} (Ord(Search.Name[I]) = 220) and not
      {ä} (Ord(Search.Name[I]) = 228) and not
      {ö} (Ord(Search.Name[I]) = 246) and not
      {ü} (Ord(Search.Name[I]) = 252) and not
      {ß} (Ord(Search.Name[I]) = 223) then
      begin
       StringGrid1.Cells[3, List.Count+1] := '    !';
       Form2.ListBox1.Items.Add('');         {... wenn ja, hierher}
       Form2.ListBox1.Items.Add('#'+Path+Search.Name);
       Form2.ListBox1.Items.Add('   Dateiname enthält Sonderzeichen'+S);
       break;
      end;

    if Stop then
    begin
     SysUtils.FindClose(Search);
     exit;
    end;

    if chklist then
    begin
     List2.Add(ExtractShortPathName(Path+Search.Name)+' '+
      IntToStr(FileSizeByName(Path+Search.Name))+' '+
       GetFileDateTime(Path+Search.Name)+' '+
        GetFileAttr(Path+Search.Name));
    end
    else
     begin
      try
       List2.LoadFromFile(Path+ChkFile);
       List2.Text := ShiftStr(List2.Text,-85);
      except
       SysUtils.FindClose(Search);
      end;
     end;

    if not (ExtractShortPathName(Path) =  {Wenn ein falscher Pfadname in ...}
     ExtractFilePath(GetWord(List2[Counter],1))) then
    begin
     if ExtractFilePath(GetWord(List2[Counter],1)) > '' then
     begin
      EraseFile(Path+ChkFile);        {... ChkFile-Datei, diese löschen, ...}
      Erased := True;
     end
     else
      Erased := False;         {... wenn hingegen eine neue Datei im Ordner,}
             {ChkFile-Datei nicht löschen und Dateiname der Liste hinzufügen}

     List2.Delete(Counter);
     List2.Text := ShiftStr(List2.Text,85);
     try  {Sonst werden immer neue CR/LF gefolgt von "b_" angehängt (??)}
      if List2[List2.Count-1] = 'b_' then List2.Delete(List2.Count-1);
     except ; end;
     List2.Text := ShiftStr(List2.Text,-85);

//     List.Add(Path+Search.Name);
//     StringGrid1.Cells[0, List.Count] := Path;
     StringGrid1.Cells[1, List.Count] := Search.Name;
     StringGrid1.Row := StringGrid1.RowCount-1;
     if List.Count > 1 then StringGrid1.RowCount := StringGrid1.RowCount+1;
     StringGrid1.Refresh;

     List2.Insert(Counter,(ExtractShortPathName(Path+Search.Name)+' '+
      IntToStr(FileSizeByName(Path+Search.Name))+' '+
       GetFileDateTime(Path+Search.Name)+' '+
        GetFileAttr(Path+Search.Name)));

     List2.Text := ShiftStr(List2.Text,85);
     try  {Sonst werden immer neue CR/LF gefolgt von "b_" angehängt (??)}
      if List2[List2.Count-1] = 'b_' then List2.Delete(List2.Count-1);
     except ; end;

     try
      if (Pos(Form3.CheckBox1.Hint, ExtractShortPathName(Path)) = 0) and
         (Pos(Form3.CheckBox2.Hint, ExtractShortPathName(Path)) = 0) and
         (Pos(Form3.CheckBox3.Hint, ExtractShortPathName(Path)) = 0) and
         (Pos(Form3.CheckBox4.Hint, ExtractShortPathName(Path)) = 0) and not
           (ExtractShortPathName(Path) = Form3.CheckBox5.Hint) and not
           (ExtractShortPathName(Path) = Form3.CheckBox6.Hint) and not
           (ExtractShortPathName(Path) = Form3.CheckBox7.Hint) and not
           (ExtractShortPathName(Path) = Form3.CheckBox8.Hint) then
       List2.SaveToFile(Path+ChkFile);
     except
      Form2.ListBox1.Items.Add('   Konnte nicht gespeichert werden: '+Path+ChkFile);
     end;

     List2.Text := ShiftStr(List2.Text,-85);

     if Erased then StringGrid1.Cells[2, List.Count] := ' KORR.'
     else
      StringGrid1.Cells[2, List.Count] := '   NEU';

     List2.Clear;
     Form2.ListBox1.Items.Add('');
     Form2.ListBox1.Items.Add('#'+Path+Search.Name);  {Dateiname fett}
     Form2.ListBox1.Items.Add('   Falscher Pfad in '+Path+ChkFile);
     Form2.ListBox1.Items.Add('   - korrigiert');
     SysUtils.FindClose(Search);
     break;
    end;

    List.Add(Path+Search.Name);
    StringGrid1.Cells[0, List.Count] := Path;
    StringGrid1.Cells[1, List.Count] := Search.Name;

    try
     if ExtractShortPathName(Path+Search.Name) = GetWord(List2[Counter],1) then
     begin
      if not (IntToStr(FileSizeByName(Path+Search.Name)) =
       GetWord(List2[Counter],2)) or not
             (GetFileDate(Path+Search.Name) =
       GetWord(List2[Counter],3)) or not
             (GetFileTime(Path+Search.Name) =
       GetWord(List2[Counter],4)) or not
             (GetFileAttr(Path+Search.Name) =
       GetWord(List2[Counter],5)) then
     begin
      if (Pos(Form3.CheckBox1.Hint, ExtractShortPathName(Path)) > 0) and
         (Pos(Form3.CheckBox2.Hint, ExtractShortPathName(Path)) > 0) and
         (Pos(Form3.CheckBox3.Hint, ExtractShortPathName(Path)) > 0) and
         (Pos(Form3.CheckBox4.Hint, ExtractShortPathName(Path)) > 0) or
           (ExtractShortPathName(Path) = Form3.CheckBox5.Hint) or
           (ExtractShortPathName(Path) = Form3.CheckBox6.Hint) or
           (ExtractShortPathName(Path) = Form3.CheckBox7.Hint) or
           (ExtractShortPathName(Path) = Form3.CheckBox8.Hint) then
      begin
       Status := ' ------------';
       StringGrid1.Cells[2, List.Count] := Status;
      end
      else
      begin
       StringGrid1.Cells[2, List.Count] := 'GEÄND.';
       Aktualisieren := True;
       if CheckBox1.Checked then Sound(400,25);
        if Form2.ListBox1.Items.Count > 0 then  {Nach jedem Dateieintrag eine}
         Form2.ListBox1.Items.Add('');    {Leerzeile, nicht aber als 1. Zeile}

                 {Dateiname fett}
        Form2.ListBox1.Items.Add('#'+StringGrid1.Cells[0, List.Count]+StringGrid1.Cells[1, List.Count]);

        {Grösse hat sich geändert}
       if not (IntToStr(FileSizeByName(Path+Search.Name)) = GetWord(List2[Counter],2)) then
       begin
        NewSize := SysUtils.FormatFloat('#,#',FileSizeByName(Path+Search.Name));
        OldSize := SysUtils.FormatFloat('#,#',StrToInt(GetWord(List2[Counter],2)));
        while Length(NewSize) < 11 do NewSize := ' '+NewSize;
        while Length(OldSize) < 11 do OldSize := ' '+OldSize;
        S := OldSize+'  '+NewSize;
        StringGrid1.Cells[4, List.Count] := S;
        Form2.ListBox1.Items.Add('   Grösse wurde geändert:');
        Form2.ListBox1.Items.Add('      Alt: '+OldSize+' Bytes   Neu: '+NewSize+' Bytes');
       end;

        {Datum hat sich geändert}
       if not (GetFileDate(Path+Search.Name) = GetWord(List2[Counter],3)) then
       begin
        StringGrid1.Cells[5, List.Count] := GetWord(List2[Counter],3)+' '+GetFileDate(Path+Search.Name);
        Form2.ListBox1.Items.Add('   Datum wurde geändert:');
        Form2.ListBox1.Items.Add('      Alt: '+GetWord(List2[Counter],3)+'   Neu: '+GetFileDate(Path+Search.Name));
       end;

        {Zeit hat sich geändert}
       if not (GetFileTime(Path+Search.Name) = GetWord(List2[Counter],4)) then
       begin
        StringGrid1.Cells[6, List.Count] := GetWord(List2[Counter],4)+' '+GetFileTime(Path+Search.Name);
        Form2.ListBox1.Items.Add('   Zeit wurde geändert:');
        Form2.ListBox1.Items.Add('      Alt: '+GetWord(List2[Counter],4)+'   Neu: '+GetFileTime(Path+Search.Name));
       end;

        {Attribut hat sich geändert}
       if not (GetFileAttr(Path+Search.Name) = GetWord(List2[Counter],5)) then
       begin
        OldSize := GetWord(List2[Counter],5);
        if OldSize = 'R'    then OldSize := 'R...';
        if OldSize = 'RH'   then OldSize := 'RH..';
        if OldSize = 'RHS'  then OldSize := 'RHS.';
        if OldSize = 'RHSA' then OldSize := 'RHSA';
        if OldSize = 'RHA'  then OldSize := 'RH.A';
        if OldSize = 'RSA'  then OldSize := 'R.SA';
        if OldSize = 'RA'   then OldSize := 'R..A';
        if OldSize = 'RS'   then OldSize := 'R.S.';
        if OldSize = 'S'    then OldSize := '..S.';
        if OldSize = 'SA'   then OldSize := '..SA';
        if OldSize = 'H'    then OldSize := '.H..';
        if OldSize = 'HA'   then OldSize := '.H.A';
        if OldSize = 'HS'   then OldSize := '.HS.';
        if OldSize = 'HSA'  then OldSize := '.HSA';
        if OldSize = 'S'    then OldSize := '..S.';
        if OldSize = 'SA'   then OldSize := '..SA';
        if OldSize = 'A'    then OldSize := '...A';
        if OldSize = ''     then OldSize := '....';

        NewSize := GetFileAttr(Path+Search.Name);
        if NewSize = 'R'    then NewSize := 'R...';
        if NewSize = 'RH'   then NewSize := 'RH..';
        if NewSize = 'RHS'  then NewSize := 'RHS.';
        if NewSize = 'RHSA' then NewSize := 'RHSA';
        if NewSize = 'RHA'  then NewSize := 'RH.A';
        if NewSize = 'RSA'  then NewSize := 'R.SA';
        if NewSize = 'RA'   then NewSize := 'R..A';
        if NewSize = 'RS'   then NewSize := 'R.S.';
        if NewSize = 'S'    then NewSize := '..S.';
        if NewSize = 'SA'   then NewSize := '..SA';
        if NewSize = 'H'    then NewSize := '.H..';
        if NewSize = 'HA'   then NewSize := '.H.A';
        if NewSize = 'HS'   then NewSize := '.HS.';
        if NewSize = 'HSA'  then NewSize := '.HSA';
        if NewSize = 'S'    then NewSize := '..S.';
        if NewSize = 'SA'   then NewSize := '..SA';
        if NewSize = 'A'    then NewSize := '...A';
        if NewSize = ''     then NewSize := '....';
        StringGrid1.Cells[7, List.Count] := OldSize+'  '+NewSize;
        Form2.ListBox1.Items.Add('   Attribut(e) wurde(n) geändert:');
        Form2.ListBox1.Items.Add('      Alt: '+OldSize+'   Neu: '+NewSize);
       end;
      end;
     end
     else    {Alles OK - keine Änderung}
     begin
      if not chklist then
       Status := '     OK'
      else
       Status := '   NEU';

      if (Pos(Form3.CheckBox1.Hint, ExtractShortPathName(Path)) > 0) or
         (Pos(Form3.CheckBox2.Hint, ExtractShortPathName(Path)) > 0) or
         (Pos(Form3.CheckBox3.Hint, ExtractShortPathName(Path)) > 0) or
         (Pos(Form3.CheckBox4.Hint, ExtractShortPathName(Path)) > 0) or
         (ExtractShortPathName(Path) = Form3.CheckBox5.Hint) or
         (ExtractShortPathName(Path) = Form3.CheckBox6.Hint) or
         (ExtractShortPathName(Path) = Form3.CheckBox7.Hint) or
         (ExtractShortPathName(Path) = Form3.CheckBox8.Hint) then
       Status := ' ------------';

      StringGrid1.Cells[2, List.Count] := Status;

      if Status = ' ------------' then
      begin
       Form2.ListBox1.Items.Add('');
       Form2.ListBox1.Items.Add('#'+Path+Search.Name);  {Dateiname fett}
       Form2.ListBox1.Items.Add('   Ignoriert');
      end;

      if Status = '   NEU' then
      begin
       Form2.ListBox1.Items.Add('');
       Form2.ListBox1.Items.Add('#'+Path+Search.Name);  {Dateiname fett}
       Form2.ListBox1.Items.Add('   Neu erfasst');
      end;
     end;
    end
    else  {Wenn keine Werte verfügbar, aus welchem Grund auch immer}
    begin                             {(kam beim Testen schon vor!)}
     if CheckBox1.Checked then Sound(200,125);
     StringGrid1.Cells[2, List.Count] := ' XXXXX';
     Fail := True;
     Form2.ListBox1.Items.Add('');
     Form2.ListBox1.Items.Add('#'+Path);  {Dateiname fett}
     Form2.ListBox1.Items.Add('   Fehler: Dateiwerte konnten nicht ermittelt werden.');
     Form2.ListBox1.Items.Add('   Gelöscht: '+Path+ChkFile);
     Form2.ListBox1.Items.Add('   Die Prüfung kann nicht fortgesezt werden.');
     Form2.ListBox1.Items.Add('   Prüfen Sie diesen Ordner erneut.');
     EraseFile(Path+ChkFile);    {ChkFile-Datei löschen}
     SysUtils.FindClose(Search);
     exit;
    end;

    StringGrid1.Row := StringGrid1.RowCount-1;
    if List.Count > 1 then StringGrid1.RowCount := StringGrid1.RowCount+1;
    StringGrid1.Refresh;

   except ; end;

    Inc(Counter);
    Application.ProcessMessages;

    if not chklist then
     if not FileExists(GetWord(List2[Counter],1)) then
     begin
      List2.Delete(Counter);

      List2.Text := ShiftStr(List2.Text,85);
      try  {Sonst werden immer neue CR/LF gefolgt von "b_" angehängt (??)}
       if List2[List2.Count-1] = 'b_' then List2.Delete(List2.Count-1);
      except ; end;

      try
      if (Pos(Form3.CheckBox1.Hint, ExtractShortPathName(Path)) = 0) and
         (Pos(Form3.CheckBox2.Hint, ExtractShortPathName(Path)) = 0) and
         (Pos(Form3.CheckBox3.Hint, ExtractShortPathName(Path)) = 0) and
         (Pos(Form3.CheckBox4.Hint, ExtractShortPathName(Path)) = 0) and not
           (ExtractShortPathName(Path) = Form3.CheckBox5.Hint) and not
           (ExtractShortPathName(Path) = Form3.CheckBox6.Hint) and not
           (ExtractShortPathName(Path) = Form3.CheckBox7.Hint) and not
           (ExtractShortPathName(Path) = Form3.CheckBox8.Hint) then
        List2.SaveToFile(Path+ChkFile);

      except
       Form2.ListBox1.Items.Add('   Konnte nicht gespeichert werden: '+Path+ChkFile);
      end;

      List2.Clear;
     end;

    until FindNext(Search) <> 0;

    SysUtils.FindClose(Search);

    if chklist then
     if List2.Count > 0 then
    begin
     List2.Text := ShiftStr(List2.Text,85);
     try  {Sonst werden immer neue CR/LF gefolgt von "b_" angehängt (??)}
      if List2[List2.Count-1] = 'b_' then List2.Delete(List2.Count-1);
     except ; end;

     try
      if (Pos(Form3.CheckBox1.Hint, ExtractShortPathName(Path)) = 0) and
         (Pos(Form3.CheckBox2.Hint, ExtractShortPathName(Path)) = 0) and
         (Pos(Form3.CheckBox3.Hint, ExtractShortPathName(Path)) = 0) and
         (Pos(Form3.CheckBox4.Hint, ExtractShortPathName(Path)) = 0) and not
           (ExtractShortPathName(Path) = Form3.CheckBox5.Hint) and not
           (ExtractShortPathName(Path) = Form3.CheckBox6.Hint) and not
           (ExtractShortPathName(Path) = Form3.CheckBox7.Hint) and not
           (ExtractShortPathName(Path) = Form3.CheckBox8.Hint) then
       List2.SaveToFile(Path+ChkFile);
     except
      Form2.ListBox1.Items.Add('   Konnte nicht gespeichert werden: '+Path+ChkFile);
     end;

     List2.Clear;
    end;

    Counter := 0;
    List2.Clear;
    finally
     try         {try, sonst Fehler, wenn der Benutzer stoppt}
      Free;
     except ; end;
    end;

    if SubFolder then
    begin
     if FindFirst(Path + '*.*', faDirectory, Search) = 0 then
     begin
      repeat
       if ((Search.Attr and faDirectory) = faDirectory) and
        (Search.Name[1] <> '.') then
         FindExecutableFiles(Path + Search.Name, Mask, List, SubFolder);

       until FindNext(Search) <> 0;
       SysUtils.FindClose(Search);
     end;
    end;

    if (Pos(Form3.CheckBox1.Hint, ExtractShortPathName(Path)) > 0) and
       (Pos(Form3.CheckBox2.Hint, ExtractShortPathName(Path)) > 0) and
       (Pos(Form3.CheckBox3.Hint, ExtractShortPathName(Path)) > 0) and
       (Pos(Form3.CheckBox4.Hint, ExtractShortPathName(Path)) > 0) or
         (ExtractShortPathName(Path) = Form3.CheckBox5.Hint) or
         (ExtractShortPathName(Path) = Form3.CheckBox6.Hint) or
         (ExtractShortPathName(Path) = Form3.CheckBox7.Hint) or
         (ExtractShortPathName(Path) = Form3.CheckBox8.Hint) then
    try
     EraseFile(Path+ChkFile);   {Eine evtl. vorhandene ChkFile-Datei löschen,}
    except ; end;  {wenn der aktuelle Ordner ein zu ignorierender ist (Form3)}

  try
   SysUtils.FindClose(Search);
  except ; end;
end;

_________________
gedunstig war's - und fahle wornen zerschellten karsig im gestrock. oh graus, es gloomt der jabberwock - und die graisligen gulpen nurmen!
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: Mo 31.05.04 09:06 
waaahnsinn, wenn ich solche Mamutproceduren lese, krieg ich immer Bauchschmerzen :-).
Was hälst du davon, zuerst mal die Funktion auseinanderzunehmen und einzelne kleinere Module zu schreiben? Das kann kein Anderer nachverfolgen.Versuch dabei, die lokalen Variablen so wenig wie möglich zu definieren und greife statt dessen auf Objekt-Variablen zurück. Es reicht ja, z.b. die FileAttribute Global einmal zu deklarieren und nicht ständig in der Funktion.
- Statt if () verwende lieber Sets z.b. if Ord(searchname[i] in (Set of Char) then ...
- Statt der Funktionen GetFileDateTime und GeFileAttr verwende die TSearch-Record Eigenschaften
Wenn Du auf die Listbox zugreifst, schreibe vor Zugriff Listbox.Items.BeginUpdate und abschließend EndUpdate. Geht schneller
Desgleichen die vielen If() mit Newsize(Attribute). Das geht einfacher mit "and"
z.b. if SearchRecord.FileAttr and faArchive = faArchive then S:=S+'A' uns so weiter

grez
msch

_________________
ist das politisch, wenn ich linksdrehenden Joghurt haben möchte?
galagher Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2562
Erhaltene Danke: 46

Windows 10 Home
Delphi 10.1 Starter, Lazarus 2.0.6
BeitragVerfasst: Mo 31.05.04 11:22 
MSCH hat folgendes geschrieben:
Was hälst du davon, zuerst mal die Funktion auseinanderzunehmen und einzelne kleinere Module zu schreiben?


Habe zunächst mal die gesamte Dateiüberprüfung optimiert, wie du vorgeschlagen hast. Die Prüfung auf Sonderzeichen im Namen klappt mit Set nicht - Leerzeichen werden als Sonderzeichen erkannt. Jetzt dauert es zwar länger bis zum Stillstand, aber der Speicher nimmt trotzdem noch ab, trotz FindClose. Anfangs läuft es stabil, der Speicher bleibt konstant hoch und sinkt dann kontiniierlich, bis er zwischen 0 und 4096 hin und her pendelt.

Das Problem liegt irgendwo in der Dateiprüfung, denn wenn ich die zur Gänze weglasse, klappt alles. Bloss, dass die Dateiprüfung der eigtl. Sinn des Programms ist! :mrgreen:

Danke für eure Hilfe, aber unter diesen Umständen werde ich's löschen. Bevor ich alles zerlege und das bringt auch nichts.

_________________
gedunstig war's - und fahle wornen zerschellten karsig im gestrock. oh graus, es gloomt der jabberwock - und die graisligen gulpen nurmen!
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: Mo 31.05.04 11:45 
kurz angemerkt was mir grad aufgefallen ist: Du übergibst "List" immer wieder an die Funktion und schreibst jedesmal was rein. -> List wird immer größer. Is das mit "abgeschaltet" wenn du diese "Dateiprüfung" weglässt? Evtl könnts da dran liegen...
[klugscheiß]
Schließlich bleiben imho Parameter und lokale Variablen solange auf dem Stack, bis die Funktion endet.
[/klugscheiß]


raziel

_________________
JSXGraph
MartinPb
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 698



BeitragVerfasst: Mo 31.05.04 11:57 
Eine Frage: welches Betriebssystem?

_________________
Gruß
Martin
galagher Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2562
Erhaltene Danke: 46

Windows 10 Home
Delphi 10.1 Starter, Lazarus 2.0.6
BeitragVerfasst: Mo 31.05.04 12:44 
raziel hat folgendes geschrieben:
kurz angemerkt was mir grad aufgefallen ist: Du übergibst "List" immer wieder an die Funktion und schreibst jedesmal was rein. -> List wird immer größer.


List ist übriggeblieben von ersten Versuchen. Ich kann auch direkt StringGrid1 nehmen, das ist aber egal. Statt List zähle ich jetzt einfach die Zeilen mit einer LongInt. Trotzdem, der Fehler tritt immer noch auf.

_________________
gedunstig war's - und fahle wornen zerschellten karsig im gestrock. oh graus, es gloomt der jabberwock - und die graisligen gulpen nurmen!
galagher Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2562
Erhaltene Danke: 46

Windows 10 Home
Delphi 10.1 Starter, Lazarus 2.0.6
BeitragVerfasst: Mo 31.05.04 12:45 
MartinPb hat folgendes geschrieben:
Eine Frage: welches Betriebssystem?


Windows Me.

_________________
gedunstig war's - und fahle wornen zerschellten karsig im gestrock. oh graus, es gloomt der jabberwock - und die graisligen gulpen nurmen!
galagher Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2562
Erhaltene Danke: 46

Windows 10 Home
Delphi 10.1 Starter, Lazarus 2.0.6
BeitragVerfasst: Mo 31.05.04 13:01 
Was auch seltsam ist, dass Windows dann so langsam bleibt: Dateien werden zT. langsam geöffnst, Delphi kompiliert zwar normal, am Ende des Vorgangs steht dann aber für Sekunden das Compiler-Fenster am Bildschirm und zeigt "Abbrechen", dann erst wechselt der Button auf "Ok" - das geht ja normal blitzschnell.

_________________
gedunstig war's - und fahle wornen zerschellten karsig im gestrock. oh graus, es gloomt der jabberwock - und die graisligen gulpen nurmen!
MartinPb
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 698



BeitragVerfasst: Mo 31.05.04 13:04 
Es gibt das leidige Thema der Ressourcen unter Windows 95 und 98 (diese Systeme haben nur 64Kbyte für die Verwaltung der Ressourcen). Müßte aber auch für Me gelten, da Me eigentlich nur ein erweitertes 98 ist. Sind unter 95 und 98 die Ressourcen verbraucht, dann geht alles in den Keller. Sowas ereicht man schon mit einfachen Löschen oder Umbenennen von Dateien. Ich schätze, daß das auch für Me gilt.

Ob es allerdings die Antwort auf dein Problem ist, weiß ich nicht. Es wäre aber eine mögliche Antwort.

_________________
Gruß
Martin
galagher Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2562
Erhaltene Danke: 46

Windows 10 Home
Delphi 10.1 Starter, Lazarus 2.0.6
BeitragVerfasst: Mo 31.05.04 13:18 
MartinPb hat folgendes geschrieben:
Sind unter 95 und 98 die Ressourcen verbraucht, dann geht alles in den Keller.

Und wie kann man Windows beibringen, dass es da nichts an meinem Prog gibt, was unbedingt im Speicher bleiben muss? Sobald ein Ordner durchgelaufen ist, weg mit dem Zeug, braucht ja keiner! Bevor ich es endgültig lösche, werde ich es mal auf einem XP-System testen! Danke!!!

_________________
gedunstig war's - und fahle wornen zerschellten karsig im gestrock. oh graus, es gloomt der jabberwock - und die graisligen gulpen nurmen!
MartinPb
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 698



BeitragVerfasst: Mo 31.05.04 13:30 
Das ist die Ressourcen-Verwaltung von Windows und die ist Müll. Der kannst du nichts beibringen. Die einzige Möglichkeit ist auf 2000 oder XP umzusteigen. Die haben die 64kByte Grenze nicht. Andere Möglichkeit wäre dein Betriebssystem neu zu installieren. Das Problem liegt nicht 100% an Windows, sondern an vielen Unterprogrammen die die Ressourcen verbrauchen. Irgendwann ist die Wanne fast voll und es reicht nur paar Dateien zu löschen um es voll zu machen. Dann geht nichts mehr, bzw. fast nichts mehr.

_________________
Gruß
Martin
biochip2
Hält's aus hier
Beiträge: 15

Win 2000

BeitragVerfasst: Mo 31.05.04 18:56 
Ich habe dein Programm nicht angesehen da aber bei rekursiven Programmem je nach Verschachtlungstiefe und der Stackspeicher zu klein gewählt Probleme bringt bis zum Absturz.
Den vor eingestellten Stackspeicher vergrössern.Ich habe bestimmt nicht recht aber eine Möglichkeit wärs.

MfG

Frank
galagher Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2562
Erhaltene Danke: 46

Windows 10 Home
Delphi 10.1 Starter, Lazarus 2.0.6
BeitragVerfasst: Mo 31.05.04 19:09 
biochip2 hat folgendes geschrieben:
Den vor eingestellten Stackspeicher vergrössern.Frank


Danke für die Antwort! Der Stackspeicher ist, oder besser, war (hab das Projekt gelöscht, hab's nur noch auf Diskette), auf Maximum. Mit einem RAM-Defrag-Programm ging es besser, aber immer noch nicht gut. Liegt offenbar doch an Windows!

Trotzdem: DANKE an alle! Hab' trotzdem wieder was gelernt!

_________________
gedunstig war's - und fahle wornen zerschellten karsig im gestrock. oh graus, es gloomt der jabberwock - und die graisligen gulpen nurmen!