Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 175
  • Last Modified:

I'm having Memory Problems on Windows 98 when running my application.

Hi,

   I'm having troubles in some computers that have Windows98 installed. We developed a LARGE application on delphi 7 and i can't run the application because the computer sends an error message of "Out of Resources", when i installed more memory on the computer sends me a "program error" .

   Someone told me that the problem was the number of objects that Windows 98 can handle so the solution was to create the forms in the moment they are going to be used and destroy them after that. So i have 2 questions :

    a) Is that the best solution ?
    b) If it is, how can i do it ?

Thanks.
0
jpmonja
Asked:
jpmonja
  • 3
  • 3
1 Solution
 
Russell LibbySoftware Engineer, Advisory Commented:
Yes, Windows 95/98 are pretty limited in the number of USER/GDI resource handles they can manage, and large scale apps tend to run into these limitations. To answer your 2 questions:

1.) Yes, limiting what delphi creates during app startup is one of the better ways to get a handle on things.
2.) This is normally handled in project options | Forms tab. Check the forms that are listed in the Auto-create section. Remove all but the one that will be the main form. Then in your code, use

var
  frmClass:    TYourFormClass;
begin

 fmrClass:=TYourFormClass.Create(Application);
 frmClass.Show;


If the forms are to be displayed modal, then use ShowModal and then .Release them when the modal call returns. By doing this, you will limit the number of handles that your application is using at any given time (by only creating what you need at the moment, and cleaning up when done).
 

Regards,
Russell




0
 
jpmonjaAuthor Commented:
Hi Russell, i'm very thankful for your quick response. Actually it works very good, it's just i have another question. How can i pass a parameter to the forms i'm creating before they gets modal ??

0
 
jpmonjaAuthor Commented:
I don't know if i have to make another question with more points or we can do it from here ?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Russell LibbySoftware Engineer, Advisory Commented:

Dealing with the additional question here is fine...

Regarding param passing; One of the simplest ways is to define a custom constructor and pass it there. As you will see below, it is very straight forward and quite easy.

eg:

type
  TMyForm        =  class(TForm)
  private
     // Private declarations
     FParam:     String;
  public
     // Public declarations
     constructor CreateWithParam(AOwner: TComponent; Param: String);
  end;

implementation
{$R *.DFM}

constructor TMyForm.CreateWithParam(AOwner: TComponent; Param: String);
begin
  // Inherited
  inherited Create(AOwner);
  // Set param
  FParam:=Param;
end;

end.

Creating an instance of the above form would be done like so:

var
  frmClass:    TMyForm;
begin

  frmClass:=TMyForm.CreateWithParam(Application, 'My Test Param String');
  try
     frmClass.ShowModal;
  finally
     frmClass.Release;
  end;

end;

You could also expose public variables from the form class, which would allow other sections of code to get/set these values after the form is created, eg:

type
  TForm1         =  class(TForm)
  private
     // Private declarations
     FParam:     String;
  public
     // Public declarations
     property    Param: String read FParam write FParam;
  end;


var
  frmClass:    TMyForm;
begin

  frmClass:=TMyForm.Create(Application);
  try
     frmClass.Param:='Test param string';
     frmClass.ShowModal;
  finally
     frmClass.Release;
  end;

end;

The choice of which to use is yours, as each mechanism has its own benefits. Hopefully this gives you some ideas to go from.

Regards,
Russell





0
 
jpmonjaAuthor Commented:
Thanks Russell, you've been very helpful.
0
 
Russell LibbySoftware Engineer, Advisory Commented:
Very welcome

Russell
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now