Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Release or Free & Low Resources

Status
Not open for further replies.

EricDraven

Programmer
Jan 17, 2002
2,999
GB
Hello again

My application is all but done now, however I have discovered that it barely runs under Win95/98/ME (Win32 API error). From all the research I have done this morning I have discovered that the problem is down to Win95,98 & ME only allocating a certain amount of memory for handles per application. I have solved the problem in my application but wondered if anyone else had stumbled across this problem?

Apparently comboboxes use 3 handles each and panels, groupboxes and various other visual components use handles when you would think perhaps they should not!

Part of my solution was to create as many forms as possible only when they are needed and then free them straight after, i.e.
Code:
  Form1 := TForm1.Create(nil);
  Form1.ShowModal;
  Form1.Free;
Reading the delphi help though, it is recommended that you use the release command. What is the difference between the two? I am using the free command so are all handles on the form released anyway?

Its a little confusing when experts are telling you two different things and saying that their solution is correct. At least on Tek-Tips I know which experts are most likely to be giving a trustworthy answer! [thumbsup]

Arte Et Labore [rockband]
 
Well.. as far as I know. The main problem is/used to be GDI memory (which I think stands for Graphic Device Interface ? But Im sure Im probably wrong.) This used to be (and probably still is) limited to a certain amount regardless of how much actual RAM is available.

Quote..


..The worst limitation of Windows is its User memory and GDI memory. These are the areas used to store window information, data for all fonts, buttons, icons, and other housekeeping things. Each of these memory areas is set at 64K because that's what Windows said it will be, and there is no way to increase it. How do you find out whether these are causing your problems? The easiest way is to get to the Program Manager, click on the Help menu, then choose About Program Manager. The last item labeled System Resources will tell you the smallest free percentage ouf of virtual memory, User memory, and GDI memory. For a more accurate picture of what is being used, find the System Resource Meter (available in the Microsoft Windows Resource Kit).
..


And yes, dynamic form management is a must really (expecially in large applications.) And yes, (AFAIK) list boxes as well as those you mentioned also can drain this memory. So perhaps limit exceptionally large lists of data being displayed ?

As for the release v.s Free method. My understanding is that "release" is specific to forms, and allows form-related even-handlers to finish before freeing resources. Whereas "Free" is a generic method of freeing an object from memory (so should also work with forms.)

Which one to use ? I think the free method should be fine the way you describe. Just maybe wrap it in a try-except block.

Hope this helps..

Opp.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top