Autor Beitrag
Deathman
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 52

Win XP
Turbo Pascal, Delphi 6, Delphi 2006
BeitragVerfasst: So 28.01.07 22:34 
Hi leute!

Ich habe ne Anzeige(Timage) die im 5 sekunden takt mit nem Timer die bilder(insgasemt 10 stück) wechselt. Problem ist, dass das teil über tage läuft und der timer mir jetzt den Arbeitsspeicher voll müllt.D.h. das die speicher Auslastung von bild zu bild größer wird(ca 4 kB pro interwall).

weiß einer was ich da machen soll?
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: So 28.01.07 23:17 
Versuch mal vor dem Laden Image1.Picture:=Nil;

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
Deathman Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 52

Win XP
Turbo Pascal, Delphi 6, Delphi 2006
BeitragVerfasst: Mo 29.01.07 20:31 
kein Plan dat funzt net
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 29.01.07 21:12 
Dann zeig doch mal Code, vermutlich gibst du da was nicht frei...

Aber ohne Code können wir dazu aber nix sagen. Poste doch einfach mal den Code, mit dem du die Bilder lädst.
Deathman Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 52

Win XP
Turbo Pascal, Delphi 6, Delphi 2006
BeitragVerfasst: Mo 29.01.07 22:09 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
procedure TNotdienstanzeige.Timer1Timer(Sender: TObject);
begin
FileListBox1.Update;
werbungimage.Picture:=NIL;
If i<FileListBox1.Count then
 Begin
  FileListBox1.ItemIndex:=i;
  werbungImage.Picture.LoadFromFile(FileListBox1.Directory+'\'+FileListBox1.Items.Strings[FileListBox1.ItemIndex]);
  inc(i);
 end else
 Begin
  i:=0;
  FileListBox1.ItemIndex:=i;
  werbungImage.Picture.LoadFromFile(FileListBox1.Directory+'\'+FileListBox1.Items.Strings[FileListBox1.ItemIndex]);
  inc(i);
 end;
end;
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 29.01.07 22:31 
Hmm, also das würde ich jetzt als richtig ansehen. Keine Ahnung, warum dabei immer mehr RAM belegt wird. :nixweiss:

Was du versuchen kannst: Es gibt in TBitmap die Methode FreeImage. Vielleicht bringt es was, das alte Bild vor dem Laden des neuen Bilds explizit freizugeben.
Deathman Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 52

Win XP
Turbo Pascal, Delphi 6, Delphi 2006
BeitragVerfasst: Di 30.01.07 00:14 
Problem ist das ich Jpegs benutzen muss und ich deshalb ein Image nehmen muss
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 30.01.07 00:43 
Moin!

Du solltest mal probieren, ob das ständige Laden nicht evtl. ein Problem darstellt, zumindest im Zusammenhang mit den VCLs oder dem Delphi-MM. :?

Ansatz: Lade alle Bilder bei Programmstart in ein array of TBitmap und weise dann nur noch daraus per .Assign() zu. :idea:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Jetstream
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 222



BeitragVerfasst: Di 30.01.07 00:47 
user profile iconDeathman hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
werbungimage.Picture:=NIL;					
Gibt Delphi ein Objekt automatisch frei, wenn man die Zeiger darauf löscht? Versuch mal "FreeAndNil(werbungimage.picture);"

_________________
Die folgenden Klangbeispiele sind Ergänzungen zum methodischen Aufbau der Textbeilage und dürfen nicht losgelöst von dieser behandelt werden.
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: Di 30.01.07 01:36 
Interessantes Problem. Ich habe versucht es zu reproduzieren, es aber nicht geschafft...Exakt dein geposteter Code mit 6 Bildern (Jpeg, 30-40kb) funktioniert bei mir ohne den RAM vollzumüllen.

Bist du sicher, dass der Fehler a) wirklich auftritt (die Speicherauslastung schwankt häufig, ist ziemlich normal) und b) dass der Fehler nicht an einer anderen Stelle auftaucht?

Darüberhinaus solltest du Narses' Hinweis auf jedenfall umsetzen. Außerdem ist es Unsinn die Filelistbox alle 5 Sekunden zu refreshen. Es sei denn der Ordner wird wirklich ständig (z.B. über das Internet) modifiziert. Da das aber wohl eher nicht der Fall ist kannst du deutlich eleganter an Pfade kommen.
NCortex
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 126

WIN 2000
D7 Enterprise
BeitragVerfasst: Di 30.01.07 02:17 
das problem kenne ich aber auch... ich hatte mal aus spaß ein programm geschrieben, was hintereinander jpg screenshots gemacht hat. wenn ich nun alle der reihe nach abgespielt hab stieg der speicherverbrauch enorm an. Ich glaube es hat was damit zutun, dass jpgs "entpackt" werden müssen, und der speicher leak dadurch entsteht.

_________________
"...by all means, do not use a hammer." (aus einer IBM Technikerdokumentation ca. 1920)
--->außer es kam von Microsoft<---
Deathman Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 52

Win XP
Turbo Pascal, Delphi 6, Delphi 2006
BeitragVerfasst: Di 30.01.07 20:09 
@Narses & Karlson

Ich kann es nciht beim Programmstart in ein array laden da sich die Anzahl der Bilder und die Bilder während der Laufzeit verändern.

@Karlson

Die Speicherauslastung Anstieg tritt auf wenn es eine weile läuft.(Ziel ist es dass es ewig läuft.)

@Jetstream

FreeAndNil() funzt mit Image.Picture net
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 30.01.07 20:36 
Moin!

user profile iconDeathman hat folgendes geschrieben:
@Narses & Karlson

Ich kann es nciht beim Programmstart in ein array laden da sich die Anzahl der Bilder und die Bilder während der Laufzeit verändern.

Du kannst mit dem dyn. Array aber auf jeden Fall dafür sorgen, dass die Bilder nur einmal geladen werden und dann nur noch zugewiesen. ;)

user profile iconDeathman hat folgendes geschrieben:
Ziel ist es dass es ewig läuft.

Das kannste sowieso vergessen... :mrgreen: Innerhalb von 30 Tagen würden ich schonmal das Programm beenden und neu starten, um den Speicher zu reorganisieren; noch besser den Rechner booten und das Proggi automatisch starten. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Deathman Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 52

Win XP
Turbo Pascal, Delphi 6, Delphi 2006
BeitragVerfasst: Di 30.01.07 20:55 
Also ich habs jetzt nochmal mit
Image.Picture:=NIL; neu compiliert und bis jetzt passiert nichts irgendwie muss da wat beim Compilieren schief gegangen sein. :oops: Naja erstmal ist dei Auslastung gleich geblieben(also kommt halt immmer aufs bild an)

das mit dem neustarten hab ich mir auch überlegt weiß aber noch keine Antwort.
hab drüber nachgedacht mein Programm in den Autostart zu setzten und von meinem Programm aus den Rechner neustarten.
Weiß aber net ob dat nötig ist da der rechner eh nur für diese Anzeige läuft und nicht anderes weiter macht, hat auch keine Internetanschluss, also er ist völlig isoliert. Also dürfte dann etwas passieren(Betriebssystem Win 98(vorerst));
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 30.01.07 23:45 
Delphi Online-Hilfe hat folgendes geschrieben:
ausblenden 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:
procedure TForm1.Button1Click(Sender: TObject);

var
 BitMap1,BitMap2 : TBitMap;
 MyFormat : Word;
begin
   BitMap2 := TBitMap.Create;
   BitMap1 := TBitMap.Create;
try
   BitMap1.LoadFromFile('c:\Program Files\common Files\Borland Shared\Images\Splash\256color\factory.bmp');
   BitMap2.Assign(BitMap1);     // BitMap1 in BitMap2 kopieren
   BitMap2.Dormant;             // GDI-Ressourcen freigeben
   BitMap2.FreeImage;           // Speicher freigeben
   Canvas.Draw(20,20,BitMap2);  // Durch die vorherigen Aufrufe geht die Grafik nicht verloren

   BitMap2.Monochrome := true;
   Canvas.Draw(80,80,BitMap2);
   BitMap2.ReleaseHandle;       // Hier wird das Bitmap freigegeben
 finally
   BitMap1.Free;
   BitMap2.Free;
 end;
end;

Vielleicht kommst du ja damit noch weiter. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Deathman Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 52

Win XP
Turbo Pascal, Delphi 6, Delphi 2006
BeitragVerfasst: Di 30.01.07 23:54 
das setzt doch aber vorraus das ich Bitmaps verwende und gerade das will ich net da Jpeg nun mal das verbreiteste Format ist und ich dem Benutzer ja nich abverlangen will, dass er nur Bitmaps raussucht die er anzeigen lassen kann.
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: Mi 31.01.07 00:05 
Du kannst den JPEG ja auch intern in einen Bitmap konvertieren ;)

_________________
Programmers never die, they just GOSUB without RETURN
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 31.01.07 00:08 
Moin!

user profile iconDeathman hat folgendes geschrieben:
das setzt doch aber vorraus das ich Bitmaps verwende und gerade das will ich net da Jpeg nun mal das verbreiteste Format ist und ich dem Benutzer ja nich abverlangen will, dass er nur Bitmaps raussucht die er anzeigen lassen kann.

Nun, was hat der Code da oben damit zu tun, NUR Bitmaps verwenden zu können... :gruebel:

Du kannst im Endeffekt eh nur eine Bitmap zur Anzeige in den Grafikkartenspeicher kopieren, ein JPEG wird wohl nur sehr schön "bunt" sein, ohne es in ein solches umzuwandeln. Da ich nicht sehr tief in der JPEG-Implementation stecke, hätte ich jetzt mal gesagt, es ist eine gute Idee die JPEGs zu laden, in ein array of TBitmap zu packen und diese von den zusätzlich genutzten Resourcen zu befreien (Beispiel s.o.) und dann nur noch aus dem array per .Assign() die Bitmaps zur Anzeige zu bringen. Das TJPEGImage kannst du dann komplett entsorgen - und damit auch alle evtl. zusammenhängenden Probleme. :mahn: :D

Wenn dein Problem sich einfach lösen ließe, dann hättest du es doch schon gelöst, oder?! :roll: ;) Vielleicht solltest du also mal alternative Ansätze in Betracht ziehen; irgendwo muss ja nun der "Speicherverbrauch" herkommen... :?:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: Mi 31.01.07 07:37 
8) Wie wäre es mit einem Durchlauf mit FastMM4 oder MemProof? Die finden doch jedes Speicherleck.

_________________
Na denn, dann. Bis dann, denn.
Deathman Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 52

Win XP
Turbo Pascal, Delphi 6, Delphi 2006
BeitragVerfasst: Do 01.02.07 18:00 
sorry wenn ich so blöd frage aber wo find ich das oder besser wie mache ich das?