Delphi-PRAXiS
Seite 1 von 4  1 23     Letzte »    

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Delphi Exception bei Programmende (https://www.delphipraxis.net/205183-exception-bei-programmende.html)

H.Bothur 10. Aug 2020 08:49

Exception bei Programmende
 
Moin,

wenn mein Programm beendet wird bekomme ich am Schluss folgende Exception:

---------------------------
Benachrichtigung über Debugger-Exception
---------------------------
Im Projekt Csv2008.exe ist eine Exception der Klasse $C0000005 mit der Meldung 'access violation at 0x00000000: read of address 0x00000000' aufgetreten.
---------------------------
Anhalten Fortsetzen Hilfe
---------------------------


Ich nehme an das ich da irgendwas nicht wieder freigegeben habe - aber ein Vergleich der verschiedenen Creates und Frees hat nichts ergeben - ich glaube (!) das ich alles auch wieder freigebe.

Wie finde ich denn raus was daran Schuld ist ?

Hans

KodeZwerg 10. Aug 2020 08:51

AW: Exception bei Programmende
 
FastMM, MadExcept, EurekaLog usw könnte dabei helfen den schuldigen zu finden.

Ps: Vielleicht hast Du auch etwas zu früh freigegen und greifst danach nochmal darauf zu....

Gausi 10. Aug 2020 08:59

AW: Exception bei Programmende
 
Zitat:

Zitat von H.Bothur (Beitrag 1471472)
Ich nehme an das ich da irgendwas nicht wieder freigegeben habe - aber ein Vergleich der verschiedenen Creates und Frees hat nichts ergeben - ich glaube (!) das ich alles auch wieder freigebe.

So ins Blaue hineingeraten würde ich eher die andere Richtung vermuten. Du hast etwas manuell freigegeben (per FreeAndNil), was eigentlich die Form noch freigeben möchte. Hast du z.B. irgendwo Komponenten zur Laufzeit erstellt und dabei einen Owner angegeben? Denn dann kümmert sich der Owner um die Freigabe am Ende.

dummzeuch 10. Aug 2020 09:22

AW: Exception bei Programmende
 
Zitat:

Zitat von Gausi (Beitrag 1471475)
Zitat:

Zitat von H.Bothur (Beitrag 1471472)
Ich nehme an das ich da irgendwas nicht wieder freigegeben habe - aber ein Vergleich der verschiedenen Creates und Frees hat nichts ergeben - ich glaube (!) das ich alles auch wieder freigebe.

So ins Blaue hineingeraten würde ich eher die andere Richtung vermuten. Du hast etwas manuell freigegeben (per FreeAndNil), was eigentlich die Form noch freigeben möchte. Hast du z.B. irgendwo Komponenten zur Laufzeit erstellt und dabei einen Owner angegeben? Denn dann kümmert sich der Owner um die Freigabe am Ende.

Aber genau in diesem Fall sollte die Komponente automatisch den Owner benachrichtigen, dass sie freigegeben wird, und deshalb keine AV auftreten.

freimatz 10. Aug 2020 09:28

AW: Exception bei Programmende
 
Dann sind es vielleicht Klassen die keinen Owner haben.
Wie sieht der Callstack aus?

H.Bothur 10. Aug 2020 09:51

AW: Exception bei Programmende
 
Liste der Anhänge anzeigen (Anzahl: 1)
Vielen Dank für Eure Hilfen, ich habe da aber nur mehrere StringList erstellt und diese alle auch richtig wieder freigegeben.
Es knallt wirklich beim beenden des Programmes - allerdings nur in der Entwicklungsumgebung - wenn ich das Programm direkt starte passiert nichts.
Und zwar hier:

begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TMainForm, MainForm);
Application.CreateForm(TMailen, Mailen);
Application.CreateForm(TAusgabeForm, AusgabeForm);
MainForm.Show;
MainForm.Verarbeitung;
end. <----------------------------------



Ob das CPU-Fenster was aussagt weiß ich nciht - ich hab da mal ein Hardcopy angehängt.

KodeZwerg 10. Aug 2020 09:58

AW: Exception bei Programmende
 
Fehlt da nicht noch irgendwo ein
Delphi-Quellcode:
Application.Run
was einen bezug zur Zeile
Delphi-Quellcode:
Application.Initialize;
hat?


Delphi-Beispiel einer .dpr Datei:
Delphi-Quellcode:
{
This example shows progress of loading forms as an
application starts up. The code example is placed in the
project source (*.dpr) file. To see project source, right
click on the executable file in the Project Manager and
select the View Source menu item. You will need to set up
your project with the following steps before using the codeexample:   Add four additional forms to a default project.
    Place a TProgressBar on Form5
    Take the Project|Options|Forms menu option and place
          Form5 on the available forms list.
    Change the code of your project (*.dpr) file to look
          like the example.
}
begin
  Application.Initialize;
  with TForm5.Create(nil) do
  try
    Application.MainFormOnTaskbar := True;
    ProgressBar1.Max := 100;
    Show; // show a splash screen contain ProgressBar control
    Update; // force display of Form5
    Application.CreateForm(TForm1, Form1);
    ProgressBar1.StepBy(25);
    Label1.Caption := 'Form1 loaded successfully.';
    Update; // force display of Form5
    Sleep(3000);
    Application.CreateForm(TForm2, Form2);
    ProgressBar1.StepBy(25);
    Label1.Caption := 'Form2 loaded successfully.';
    Update; // force display of Form5
    Sleep(3000);
    Application.CreateForm(TForm3, Form3);
    ProgressBar1.StepBy(25);
    Label1.Caption := 'Form3 loaded successfully.';
    Update; // force display of Form5
    Sleep(3000);
    Application.CreateForm(TForm4, Form4);
    ProgressBar1.StepBy(25);
    Label1.Caption := 'Form4 loaded successfully.';
    Update; // force display of Form5
    Sleep(3000);
  finally
    Free;
  end;
  Application.Run;

H.Bothur 10. Aug 2020 10:13

AW: Exception bei Programmende
 
Die komplette .dpr sieht so aus ....

program Csv2008;

{$R *.dres}

uses
Vcl.Forms,
Csv2008Main in 'Csv2008Main.pas' {MainForm},
MailenUnit in 'MailenUnit.pas' {Mailen},
RecordUnit in 'RecordUnit.pas',
AusgabeUnit in 'AusgabeUnit.pas' {AusgabeForm};

{$R *.res}

begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TMainForm, MainForm);
Application.CreateForm(TMailen, Mailen);
Application.CreateForm(TAusgabeForm, AusgabeForm);
MainForm.Show;
MainForm.Verarbeitung;
end.

Es kann aber sein das das daran liegt das ich mir mal zerschossen hatte :-( Aber bis auf die Exception in der Entwicklungsumgebung läuft alles :-)

Hans

Uwe Raabe 10. Aug 2020 10:25

AW: Exception bei Programmende
 
Das ist auf jeden Fall keine Standard DPR. Statt MainForm.Show und MainForm.Verarbeitung sollte da ein Application.Run stehen. Aber wir wissen ja auch nicht, was in MainForm.Verarbeitung so alles passiert.

KodeZwerg 10. Aug 2020 10:25

AW: Exception bei Programmende
 
Zitat:

Zitat von H.Bothur (Beitrag 1471491)
Delphi-Quellcode:
program Csv2008;

{$R *.dres}

uses
  Vcl.Forms,
  Csv2008Main in 'Csv2008Main.pas' {MainForm},
  MailenUnit in 'MailenUnit.pas' {Mailen},
  RecordUnit in 'RecordUnit.pas',
  AusgabeUnit in 'AusgabeUnit.pas' {AusgabeForm};

{$R *.res}

begin
  Application.Initialize;
  Application.MainFormOnTaskbar := True;
  Application.CreateForm(TMainForm, MainForm);
  Application.CreateForm(TMailen, Mailen);
  Application.CreateForm(TAusgabeForm, AusgabeForm);
  Application.Run;
end.

Das Formular "MainForm" sollte "Visible = True" als Eigenschaft bekommen.
Im Formular "MainForm" ein "OnCreate" erzeugen mit "Verarbeitung" als Aufruf.

Versuche das mal.


Alle Zeitangaben in WEZ +1. Es ist jetzt 11:44 Uhr.
Seite 1 von 4  1 23     Letzte »    

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz