| Autor |
Beitrag |
meolus
      
Beiträge: 78
Gentoo, Debian, Win7 64-bit, WinXP
Delphi 2006 Prof., Delphi 2005 PE
|
Verfasst: Mo 12.03.07 01:40
Hallo Leute ich habe folgende Funktion, welche in meinem Programm von einem Timer ausgelöst immer wieder aufgerufen wird. Jedoch frisst diese Funktion, wie tests bestätigt haben, den Arbeitsspeicher laut Taskmanager. Nach einiger Zeit bekomme ich nen Fehler vom System, dass die Anwendung keine freien Systemrescourcen mehr finden kann und schmiert ab. Wenn ich diese Funktion auskommentiere, dann steigt der Speicherverbrauch laut Taskmanager nicht mehr so stark an. Wo sind da bitte noch Speicherlücken? Ich gebe doch die 2 benutzen Objekte wieder frei?!
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:
| function TMainForm.GetTrayIcon(idx: Integer): TIcon; var Bitmap: TBitmap; ImageList: TImageList; ctemp: string; begin Bitmap := TBitmap.Create; Bitmap.SetSize(16, 16); Bitmap.Canvas.Pen.Color := clBlue;
ctemp := IntToStr(NORMALERWEISE_ZWEI_STELLIGER_INT); case Length(ctemp) of 1: begin Bitmap.Canvas.TextOut(1, 2, ' '); Bitmap.Canvas.TextOut(7, 2, ctemp[1]); end; 2: begin Bitmap.Canvas.TextOut(1, 2, ctemp[1]); Bitmap.Canvas.TextOut(7, 2, ctemp[2]); end; else begin Bitmap.Canvas.TextOut(1, 2, '-'); Bitmap.Canvas.TextOut(7, 2, '-'); end; end;
result := TIcon.Create; ImageList := TImageList.Create(nil); ImageList.AddMasked(Bitmap, clWhite); ImageList.GetIcon(0, result); ImageList.Clear; ImageList.Free; Bitmap.Free; end; |
Mfg Meolus
_________________ Real programmers don't comment their code;
if it was hard to write, it should be hard to read.
|
|
HelgeLange
      
Beiträge: 735
Erhaltene Danke: 6
Windows 7
Delphi7 - Delphi XE
|
Verfasst: Mo 12.03.07 02:32
Gibst du das TIcon auch irgendwo wieder frei?
_________________ "Ich bin bekannt für meine Ironie. Aber auf den Gedanken, im Hafen von New York eine Freiheitsstatue zu errichten, wäre selbst ich nicht gekommen." - George Bernhard Shaw
|
|
meolus 
      
Beiträge: 78
Gentoo, Debian, Win7 64-bit, WinXP
Delphi 2006 Prof., Delphi 2005 PE
|
Verfasst: Mo 12.03.07 11:57
Ich benutze diese TrayIcon-Komponenten: www.swissdelphicente...showcode.php?id=1303
Ich weise es einfach der Eigenschaft zu:
Delphi-Quelltext 1:
| TrayIcon.Icon := GetTrayIcon(i); |
Ich hab zwar auch schonmal nen "TrayIcon.Icon.Free;" davor gesetzt, daber dann hat der auf einmal immer nur noch das Application.Icon im Systray angezeigt.
---
Habs grad nochmal versucht, und jetzt geht das mit dem Icon.Free :-/
Hat sich also erledigt, wenn da jetzt nicht irgendwo wirklichen nen Bug in der Komponenten ist, dem ich da immer auf den Leim gehe.
_________________ Real programmers don't comment their code;
if it was hard to write, it should be hard to read.
|
|
wulfskin
      
Beiträge: 1349
Erhaltene Danke: 1
Win XP
D5 Pers (SSL), D2005 Pro, C, C#
|
Verfasst: Mo 12.03.07 12:03
Hallo,
versuchs mal so: Delphi-Quelltext 1: 2: 3:
| Icon := GetTrayIcon(bla); TrayIcon.Icon.Assign(Icon); Icon.Free; | Gruß Hape!
|
|
meolus 
      
Beiträge: 78
Gentoo, Debian, Win7 64-bit, WinXP
Delphi 2006 Prof., Delphi 2005 PE
|
Verfasst: Mo 12.03.07 13:55
_________________ Real programmers don't comment their code;
if it was hard to write, it should be hard to read.
|
|
|