Zdravím... mám takový problém...
Mám program, který potřebuji mít spuštěn delší dobu, ale do paměti se pořád něco ukládá a po 2 hodinách program spadne...
potřeboval bych zjistit co a kde se ukládá a co mám mazat... ale nevím jak to mám zjistit
Fórum › Delphi
Jak sledovat proměnné a jejich zabírání v paměti

To KIIV : a v delphi přímo není nějaká utilitka?
To KIIV : aha... no to mi asi moc nepomůže.. já bych potřeboval vědět, která proměnná, nebo komponenta využívá tolik místa místo, abych věděl co mazat...
To Krychlik : to jsem udělal... program funguje dokonale, jen se každých 10 vteřin do paměti zapíše asi 50KB a nevím kde se tam berou... vůbec nevím v jaké proměnné...
To KIIV : protože se to píše jen když je zapnutý časovač a ten běží jen 5 vteřin a něž to odkrokuju, tak bude po a nebudu vědět co se přidalo... už jsem to zkoušel...
To KIIV : to zas nevím jak se dělá :D
tak hod kod.. treba to bude jak pest na oko ze nekde budes furt vytvaret nejakej objekt a po skonceni platnosti ho nebudes rusit pomoci free nebo destroy (ted uz nevim)
To Anonymní uživatel : Dela se to tak, ze si pro kazdy typ udelas integer a pri vytvareni zvetsis o1, pri uvolneni zase odectes. Jednou za cas si je das vypsat a ten, ktery se bude zvetsovat, ti ukazuje, kde priblizne je problem.
To KIIV :
var
Form1: TForm1;
bmp:TBitmap;
souradnice: TPoint;
x1,y1,x2,y2,i:integer;
selection:boolean;
pocet,sazka,cas:integer;
barvy:array of string[1];
//tlacitka
MZelena,MCerna,MCervena:integer;
CZelena,CCerna,CCervena:integer;
procedure TForm1.Timer1Timer(Sender: TObject);
var j:integer;
barva:string[1];
begin
barva:='0';
bmp:=TBitmap.Create;
bmp.Assign(VytvorScreen);
for i:=0 to bmp.Width-1 do
for j:=0 to bmp.Height-1 do begin
if bmp.Canvas.Pixels[i,j] = rgb(0,0,0) then begin
barva:='1'; // ČERNÁ
Break;
end else if bmp.Canvas.Pixels[i,j] = rgb(197,26,38) then begin
barva:='2'; // ČERVENÁ
Break;
end else if bmp.Canvas.Pixels[i,j] = rgb(33,138,63) then begin
barva:='3'; // ZELENÁ
Break;
end;
end;
if (barva='1') or (barva='2') or (barva='3') then
begin
timer1.Enabled:=false;
if ListBox1.Items.Count>18 then
begin
ScrollBar1.Enabled:=true;
ScrollBar1.Min:=0;
ScrollBar1.max:=ListBox1.Items.Count-17;
end;
if barva='1' then
begin
Label4.Caption:='černá';
label4.Font.color:=clblack;
SetLength(barvy,length(barvy)+1);
barvy[high(barvy)]:=barva;
for i:=ListBox1.Items.Count downto 1 do
ListBox1.Items[i]:=ListBox1.Items[i-1];
ListBox1.Items[0]:='####';
for i:=ListBox2.Items.Count downto 1 do
ListBox2.Items[i]:=ListBox2.Items[i-1];
ListBox2.Items[0]:='';
for i:=ListBox3.Items.Count downto 1 do
ListBox3.Items[i]:=ListBox3.Items[i-1];
ListBox3.Items[0]:='';
for i:=ListBox4.Items.Count downto 1 do
ListBox4.Items[i]:=ListBox4.Items[i-1];
ListBox4.Items[0]:='';
end
else
if barva='2' then
begin
Label4.Caption:='červená';
label4.Font.color:=clred;
SetLength(barvy,length(barvy)+1);
barvy[high(barvy)]:=barva;
for i:=ListBox1.Items.Count downto 1 do
ListBox1.Items[i]:=ListBox1.Items[i-1];
ListBox1.Items[0]:='';
for i:=ListBox2.Items.Count downto 1 do
ListBox2.Items[i]:=ListBox2.Items[i-1];
ListBox2.Items[0]:='####';
for i:=ListBox3.Items.Count downto 1 do
ListBox3.Items[i]:=ListBox3.Items[i-1];
ListBox3.Items[0]:='';
for i:=ListBox4.Items.Count downto 1 do
ListBox4.Items[i]:=ListBox4.Items[i-1];
ListBox4.Items[0]:='';
end
else
if barva='3' then
begin
Label4.Caption:='zelená';
label4.Font.color:=cllime;
SetLength(barvy,length(barvy)+1);
barvy[high(barvy)]:=barva;
for i:=ListBox1.Items.Count downto 1 do
ListBox1.Items[i]:=ListBox1.Items[i-1];
ListBox1.Items[0]:='';
for i:=ListBox2.Items.Count downto 1 do
ListBox2.Items[i]:=ListBox2.Items[i-1];
ListBox2.Items[0]:='';
for i:=ListBox3.Items.Count downto 1 do
ListBox3.Items[i]:=ListBox3.Items[i-1];
ListBox3.Items[0]:='##';
for i:=ListBox4.Items.Count downto 1 do
ListBox4.Items[i]:=ListBox4.Items[i-1];
ListBox4.Items[0]:='';
end;
end;
if pocet>=0 then
begin
Timer2.Interval:=(random(6958)+3000);
end else
if pocet>0 then
begin
Timer2.Interval:=(random(2000)+2500);
end else
if pocet>1 then
begin
Timer2.Interval:=(random(3698)+4593);
end else
if pocet>2 then
begin
Timer2.Interval:=(random(2986)+5874);
end else
if pocet>3 then
begin
Timer2.Interval:=(random(4613)+2983);
end else
if pocet>4 then
begin
Timer2.Interval:=(random(5968)+4168);
end else
if pocet>5 then
begin
Timer2.Interval:=(random(2469)+2948);
end else
if pocet>6 then
begin
Timer2.Interval:=(random(3698)+1597);
end else
if pocet>7 then
begin
Timer2.Interval:=(random(5897)+3647);
end else
if pocet>8 then
begin
Timer2.Interval:=(random(6000)+5739);
end else
if pocet>9 then
begin
Timer2.Interval:=(random(6000)+6138);
end else
if pocet>10then
begin
Timer2.Interval:=(random(6000)+7691);
end else
if pocet>11then
begin
Timer2.Interval:=(random(7000)+8039);
end else
if pocet>12then
begin
Timer2.Interval:=(random(8000)+9109);
end else
if pocet>13then
begin
Timer2.Interval:=(random(9000)+10436);
end;
bmp.Free;
end;
function TForm1.VytvorScreen():TBitmap;
var
Desktop: HDC;
begin
Result := TBitmap.Create;
Desktop := GetDC(0);
try
try
Result.PixelFormat := pf32bit;
Result.Width := x2-x1;
Result.Height := y2-y1;
BitBlt(Result.Canvas.Handle, 0, 0, Result.Width, Result.Height, Desktop, x1, y1, SRCCOPY);
Result.Modified := True;
finally
ReleaseDC(0, Desktop);
end;
except
Result.free;
Result := nil;
end;
end;
Jsem teprve na škole, tak některé věci co by se dali napsat líp moc neřeš :-) Jinak to musí být v tomto, protože se to zapisuje vždy, když je tento Timer zapnutý
To KIIV : aha... a jak bych to tedy měl napsat?
To KIIV : ahaaaa... já právě byslel, že se překresluje...

Přidej příspěvek
Ano, opravdu chci reagovat → zobrazí formulář pro přidání příspěvku
×Vložení zdrojáku
×Vložení obrázku
×Vložení videa
































Uživatelé prohlížející si toto vlákno
Podobná vlákna
Základní typy proměnných a jejich reprezentace v paměti — založil Gooo
Jak sledovat klávesnici? — založil tonez
Jak sledovat update databáze? — založil Ondřej
Jak webcamerou sledovat object z webu — založil houdis
Ruzne zpusoby jak sledovat sit — založil hok