EOutOfResources problem

I write a very large application (a lot of forms, all created at the beginning). When the application reached a certain size, I got an EOutOfResources exception.

One of the dominant side effects is that when the application is running, from some point it refuses to open windows, does not show pop-up menus or parts of them.

at the help they say it is because too much handles are in use, but I tried solutions that would work if this is the reason, and they didn't work. Furthermore , I wrote an application that opens hundreds of forms,buttons .. without
any error .
I work on a computer with 200MB Ram , so memory is not the
problem.

anyway , i would like to know , what are the various reasons
to get the EOutOfResources exception , and how can i trap resource leak (NT 4.0 environment  ) ?

Thanks , Ori.
orisAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ronit051397Commented:
Are all your forms loaded when the project is loaded?
If yes, Then load only the neccessary forms for the current operation.
When you close a form do you call Release?
If not, then on the form close event you should call Release;
Did you verify that none neccessary objects are freed?
Use Numega to locate memory leaks.

Ronit,
Kfar Saba

0
ZifNabCommented:
about memory leaks :

There are some commercial programs on the net for finding such leaks.
But, I found one, which is freeware and is good, you can find it at  : http://home.sprynet.com/sprynet/rrm/. It calls snoop.

If you can't find it, i can send it to you

Good luck!
Regards,
ZifNab.
0
MatveyCommented:
Ronit...I thougth you are from Israel!

Me too, I'm from Petach-Tiqa...

Matvey
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

JimBob091197Commented:
What ver of Delphi?
0
interCommented:
Causes
------
EOutofResources error is reported by the Windows whenever a handle is to be created or new class is to be registered to the system. Any handle creation function (DC, menu,window-form) returns 0 and Delphi interpret this as a OutofResources error.
By my opinion this is not correct, or one step more is needed to understand the actual error.The delphi should call GetLastError, but it does not.
When I search this error in VCL source code I found that it is in the following units:  Graphics, Forms, Menus.

Limits
------
Windows 95 is limitted to 16384 handles per object class, i.e. this much of menu or window locks up the system. However Windows NT does not have a restriction on number of handles.


Suggestions
-----------
Asside from the other friends suggestions I have the following:
1 - If you are creating several TCanvas, TPen, TBrush, TMetafile etc.(in general memory consuming GDI objects), be sure to call Free for them.
2 - As a rule of thumb do not precreate more than 20 such resources on FormCreate.
3 - Remember that out of resources error is cummulative. i.e. it may not appear at the begining; by forgetting to release handles the system resources may be used up gradualy.
4 - If you sure that you free the handles allocated by your program (manualy by calling constructors of TCanvas, TPen etc), try to maintain the list of handles manualy created by
program and FREE them ALL in ExitProc or finalization section. Because when your program terminated erronously some of the Free methods may not be called
5 - If you are making use of large bitmaps just for painting the background of forms etc. Create bitmap, paint it and release it if you are not doing time critical painting (animation).

GOOD LUCK!
0
orisAuthor Commented:
I'd like to add some details:
- I'm working on Delphi 2.0
- I tried BoundsChecker and it gave me only information about minor memory/resource leaks
- The NT task manager says that I'm using no more than 1400 handles at a time.
- The failure happens even if I shutdown the computer and then execute the application (there are no remains of executions from the past), before I have the chance to use any exit routines.
- My application is a large MDI application. Dozens of forms are created in the dpr file as MDI childs.
- There are almost no dynamic creations in the FormCreates. I do use Free.
- I would like to emphasize that I suspect Pop-up menus and commands like ShowMessage or MessageDlg, which create new windows.

thanks.
0
interCommented:
oris,
-I am still working on it but could not find menu or window related cause for your problem.
-However, (probably you know these but) there are two things to remind. First of all there is a patch of System.pas which fixes a 32 bytp memory leak in allocation. It is directly available from
http://www.borland.com/devsupport/delphi/downloads/index.html
-And while I try to determine the cause of the problem, I have found that suspended TThread (classes.pas) instance keeps the program from terminating. But, I still use Delphi 2.00, this problem may be fixed in 2.01.
-Also, there is a component called SNOOP for detecting memory leaks etc from http://sunsite.icm.edu.pl/delphi/ zipped into snoop110.zip

Please, write comments, I really interested the problem, the EXPERT points are not important.

Regards,
Igor

0
orisAuthor Commented:
I solved the problem by using less handles.
Igor, I'd like to give you the points, but I can't do that until you submit another answer.

thanks.
0
interCommented:
Thank you very much oris,
However, to gain that much points I'd like to do more for you. Tell me if I can help in Delphi or windows stuff (component-utility etc.)
Thanks again,
Igor
0
orisAuthor Commented:
Igor,
I really don't need anything, and I do not expect anything. If you think you got really cool stuff, with no regard to my question, you are welcomed to send it to me. My email is
oris@math.tau.ac.il.

thanks. (please submit an answer).
0
interCommented:
Thanks friend,

Have a nice programming.

Igor (inter@kosgeb.tekmer.gov.tr)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.