"Stefan Cruysberghs" <stefa...@yucom.be> skrev i melding
news:wi8k5.28$Rk5.657@nreader1.kpnqwest.net...
Quote
> Hello
> We have some serious problems with our EXE (compiled with Delphi 5 and SP1)
> on Windows 98 PC's. On Windows NT or Windows 2000 everything is working
> fine.
> Because one of our EXE's is almost 14 Mb we had to make some BPL because
> such a big EXE won't start on Win98.
> When we tested this EXE on Win98 (second release) we got some Access
> violations (in Kernel32.EXE) and Exceptions (EOutOfResources). More or less
> RAM doesn't seam to be a solution. We use a Oracle database but it makes no
> difference if it is version 8.0.4, 8.1.5, client or personal.
> Because some of these errors mentioned some of our BPL's, we tested another
> smaller EXE (6 Mb) without BPL's but the errors returned.
> Has someone had these problems when working on Windows 98 ? Is this a
> Windows 98 or a Delphi problem ? Are there solutions ?
It sounds like your application occupies far too much Windows resources, the
EAccessViolation and EOutOfResources points in this direction. To be able to
create a 14 Mb .exe file, you have to have put a lot of graphics or other big
objects in designtime. This is asking for trouble, if not done with
raffinement.
In a way, it's a Delphi problem - you end up with this trouble when adding a
large number of forms to your project and let them all be created upon
startup and freed first on termination. Although using a few hundred Mb's of
RAM wouldn't necessarily be a problem, creating a large number of controls
is. The GDI resources (window handles, canvases, bitmaps, brushes, etc.) are
limited and more RAM doesn't help.
There are a few things you should do:
1. Don't create forms before you need them, and as a general rule - free them
when they close. One easy way to accomplis this, is shown here:
TForm1 = class(TForm)
...
procedure Form1FormClose(Sender: TObject; var Action: TCloseAction);
procedure Form1FormDestroy(Sender: TObject);
....
end;
procedure OpenForm1;
var
Form1: TForm1;
procedure OpenForm1;
begin
if Form1 = nil then
Form1:=TForm1.Create(Application); // Only create if not allready
existing...
Form1.Show;
end;
procedure TForm1.Form1FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action:=caFree; // Forces form destruction when closing it...
end;
procedure TForm1.Form1FormDestroy(Sender: TObject);
begin
Form1:=nil; // You need this for OpenForm; procedure...
end;
2. Remove the form from Auto-create forms in Project | Options | Forms
dialog.
... now this form only occupies resources while actually visible. The
problem, of course, may be that you loose all information kept by objects in
this form. No way around this other than saving the information and restoring
the form's "state" in code.
Start with the non-essential forms, because here you loose little from doing
it this way. More complex, frequently used forms may then be used as is,
hopefully.
Additionally, you may have problems with memory leaks, that is, creating the
same objects again and again without freeing them after use. There are quite
a few tools around (BoudsChecker, MemProof & more) to check for mamory leaks.
An application using more than, say, 20% of Windows' resources (check with
Resource Meter in Windows Accessories menu) represents potential trouble.
Good luck !
--
Bjoerge Saether
Consultant / Developer
Asker, Norway
bsaether.removet...@online.no (remove the obvious)